mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 21:10:33 +05:00
merge ttk branch to master
This commit is contained in:
parent
6ab4195c8d
commit
c98a55ab11
158
CMakeLists.txt
158
CMakeLists.txt
@ -66,7 +66,11 @@ if(NOT INSTALL_DIR)
|
|||||||
set(INSTALL_DIR "/opt/netgen" CACHE PATH "Prefix prepended to install directories")
|
set(INSTALL_DIR "/opt/netgen" CACHE PATH "Prefix prepended to install directories")
|
||||||
endif(NOT INSTALL_DIR)
|
endif(NOT INSTALL_DIR)
|
||||||
|
|
||||||
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "Prefix prepended to install directories" FORCE)
|
if(APPLE)
|
||||||
|
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}/Netgen.app/Contents/Resources" CACHE INTERNAL "Prefix prepended to install directories" FORCE)
|
||||||
|
else(APPLE)
|
||||||
|
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "Prefix prepended to install directories" FORCE)
|
||||||
|
endif(APPLE)
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# use rpath
|
# use rpath
|
||||||
@ -89,7 +93,15 @@ include_directories ("${PROJECT_BINARY_DIR}")
|
|||||||
|
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${PROJECT_SOURCE_DIR}/cmake_modules")
|
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${PROJECT_SOURCE_DIR}/cmake_modules")
|
||||||
set(ng_install_dir RUNTIME DESTINATION bin COMPONENT netgen LIBRARY DESTINATION lib COMPONENT netgen_devel ARCHIVE DESTINATION lib COMPONENT netgen_devel)
|
|
||||||
|
if(APPLE)
|
||||||
|
set(ng_install_dir_bin ../MacOS)
|
||||||
|
set(ng_install_dir_lib ../MacOS)
|
||||||
|
else(APPLE)
|
||||||
|
set(ng_install_dir_bin bin)
|
||||||
|
set(ng_install_dir_lib lib)
|
||||||
|
endif(APPLE)
|
||||||
|
set(ng_install_dir RUNTIME DESTINATION ${ng_install_dir_bin} COMPONENT netgen LIBRARY DESTINATION ${ng_install_dir_lib} COMPONENT netgen_devel ARCHIVE DESTINATION ${ng_install_dir_lib} COMPONENT netgen_devel)
|
||||||
|
|
||||||
include (CheckIncludeFiles)
|
include (CheckIncludeFiles)
|
||||||
check_include_files (dlfcn.h HAVE_DLFCN_H)
|
check_include_files (dlfcn.h HAVE_DLFCN_H)
|
||||||
@ -147,19 +159,19 @@ include_directories(${ZLIB_INCLUDE_DIRS})
|
|||||||
#######################################################################
|
#######################################################################
|
||||||
if (USE_GUI)
|
if (USE_GUI)
|
||||||
set(CMAKE_THREAD_PREFER_PTHREAD ON)
|
set(CMAKE_THREAD_PREFER_PTHREAD ON)
|
||||||
find_package(TclStub 8.5 REQUIRED)
|
find_package(TCL 8.5)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
find_package(X11 REQUIRED)
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(OPENGL_glu_LIBRARY "/opt/X11/lib/libGLU.dylib")
|
find_library(OPENGL_gl_LIBRARY AppKit REQUIRED)
|
||||||
set(OPENGL_gl_LIBRARY "/opt/X11/lib/libGL.dylib")
|
else(APPLE)
|
||||||
|
find_package(X11 REQUIRED)
|
||||||
endif(APPLE)
|
endif(APPLE)
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
find_library(LIBPTHREAD NAMES pthread HINTS ${MY_LIB_DIR} )
|
find_library(LIBPTHREAD NAMES pthread HINTS ${MY_LIB_DIR} )
|
||||||
|
|
||||||
add_definitions(-DTCL -DOPENGL)
|
add_definitions(-DTCL -DOPENGL)
|
||||||
include_directories(${TCL_INCLUDE_PATH})
|
include_directories(${TCL_INCLUDE_PATH})
|
||||||
# include_directories(${TK_INCLUDE_PATH})
|
include_directories(${TK_INCLUDE_PATH})
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
get_filename_component(MY_LIB_DIR ${TK_LIBRARY} DIRECTORY)
|
get_filename_component(MY_LIB_DIR ${TK_LIBRARY} DIRECTORY)
|
||||||
@ -170,7 +182,12 @@ if (USE_GUI)
|
|||||||
install( DIRECTORY "${MY_LIB_DIR}/../bin" DESTINATION . COMPONENT netgen )
|
install( DIRECTORY "${MY_LIB_DIR}/../bin" DESTINATION . COMPONENT netgen )
|
||||||
else(WIN32)
|
else(WIN32)
|
||||||
set(LIBTOGL togl)
|
set(LIBTOGL togl)
|
||||||
ADD_DEFINITIONS(-DTOGL_X11)
|
add_definitions(-DUSE_TOGL_2)
|
||||||
|
if(APPLE)
|
||||||
|
ADD_DEFINITIONS(-DTOGL_NSOPENGL)
|
||||||
|
else(APPLE)
|
||||||
|
ADD_DEFINITIONS(-DTOGL_X11)
|
||||||
|
endif(APPLE)
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
endif (USE_GUI)
|
endif (USE_GUI)
|
||||||
|
|
||||||
@ -272,16 +289,29 @@ endif(INSTALL_PROFILES)
|
|||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
if(INSTALL_DEPENDENCIES)
|
if(INSTALL_DEPENDENCIES)
|
||||||
include (InstallRequiredSystemLibraries)
|
include (InstallRequiredSystemLibraries)
|
||||||
message("***********************************************")
|
find_library(LIBGOMP NAMES gomp.1)
|
||||||
find_library(LIBGOMP NAMES gomp.1)
|
find_library(LIBSTDCXX NAMES stdc++.6)
|
||||||
find_library(LIBSTDCXX NAMES stdc++.6)
|
find_library(LIBGCCS NAMES gcc_s.1)
|
||||||
message("gomp: ${LIBGOMP}")
|
install( FILES "${Boost_LIBRARIES}" ${LIBGOMP} ${LIBSTDCXX} ${LIBGCCS} DESTINATION ${ng_install_dir_lib} COMPONENT netgen )
|
||||||
message("stdc++: ${LIBSTDCXX}")
|
get_filename_component(MY_LIB_DIR ${TK_LIBRARY} DIRECTORY)
|
||||||
get_filename_component(MY_LIB_DIR ${TK_LIBRARY} DIRECTORY)
|
if(APPLE)
|
||||||
message("my_tcl lib dir: ${MY_LIB_DIR}")
|
install( DIRECTORY "${TIX_LIBRARY}" DESTINATION ${ng_install_dir_lib} COMPONENT netgen )
|
||||||
install( DIRECTORY "${MY_LIB_DIR}" DESTINATION . COMPONENT netgen )
|
install( DIRECTORY "${TK_DND_LIBRARY}" DESTINATION ${ng_install_dir_lib} COMPONENT netgen )
|
||||||
install( FILES "${Boost_LIBRARIES}" ${LIBGOMP} ${LIBSTDCXX} DESTINATION lib COMPONENT netgen )
|
endif(APPLE)
|
||||||
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/fixup.cmake "\
|
||||||
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/netgen_fixup.cmake)
|
||||||
|
set(APP ${INSTALL_DIR}/Netgen.app)
|
||||||
|
message(\${APP})
|
||||||
|
|
||||||
|
file(GLOB libs ${CMAKE_INSTALL_PREFIX}/${ng_install_dir_lib}/*.dylib ${CMAKE_INSTALL_PREFIX}/${ng_install_dir_lib}/*.so)
|
||||||
|
# set(libs ${CMAKE_INSTALL_PREFIX}/${ng_install_dir_lib}/libTix8.4.3.dylib)
|
||||||
|
message(\"\${libs}\")
|
||||||
|
netgen_fixup_bundle( \${APP}/Contents/MacOS/netgen_main \"\${libs}\" ${CMAKE_INSTALL_PREFIX}/${ng_install_dir_lib} )
|
||||||
|
execute_process(COMMAND ln -s /Applications ${INSTALL_DIR}/Applications)
|
||||||
|
execute_process(COMMAND hdiutil create -volname Netgen -srcfolder ${INSTALL_DIR} -ov -format UDZO Netgen.dmg)
|
||||||
|
")
|
||||||
|
add_custom_target(bundle COMMAND ${CMAKE_COMMAND} "-P" "${CMAKE_CURRENT_BINARY_DIR}/fixup.cmake")
|
||||||
endif(INSTALL_DEPENDENCIES)
|
endif(INSTALL_DEPENDENCIES)
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
||||||
@ -305,15 +335,15 @@ include(CTest)
|
|||||||
#######################################################################
|
#######################################################################
|
||||||
# Debian packager
|
# Debian packager
|
||||||
|
|
||||||
set(CPACK_SOURCE_GENERATOR "TGZ")
|
|
||||||
set(CPACK_SOURCE_IGNORE_FILES "/cmake/;/build/;/.gz/;~$;${CPACK_SOURCE_IGNORE_FILES}")
|
|
||||||
set(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION} )
|
|
||||||
|
|
||||||
set(CPACK_PACKAGE_NAME netgen)
|
|
||||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "automatic 3d tetrahedral mesh generator")
|
|
||||||
set(CPACK_PACKAGE_DESCRIPTION "NETGEN is an automatic 3d tetrahedral mesh generator. It accepts input from constructive solid geometry (CSG) or boundary representation (BRep) from STL file format. The connection to a geometry kernel allows the handling of IGES and STEP files. NETGEN contains modules for mesh optimization and hierarchical mesh refinement. Netgen is open source based on the LGPL license. It is available for Unix/Linux and Windows.")
|
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
|
set(CPACK_SOURCE_GENERATOR "TGZ")
|
||||||
|
set(CPACK_SOURCE_IGNORE_FILES "/cmake/;/build/;/.gz/;~$;${CPACK_SOURCE_IGNORE_FILES}")
|
||||||
|
set(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION} )
|
||||||
|
|
||||||
|
set(CPACK_PACKAGE_NAME netgen)
|
||||||
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "automatic 3d tetrahedral mesh generator")
|
||||||
|
set(CPACK_PACKAGE_DESCRIPTION "NETGEN is an automatic 3d tetrahedral mesh generator. It accepts input from constructive solid geometry (CSG) or boundary representation (BRep) from STL file format. The connection to a geometry kernel allows the handling of IGES and STEP files. NETGEN contains modules for mesh optimization and hierarchical mesh refinement. Netgen is open source based on the LGPL license. It is available for Unix/Linux and Windows.")
|
||||||
|
|
||||||
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/netgen")
|
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/netgen")
|
||||||
execute_process(COMMAND grep CODENAME /etc/lsb-release OUTPUT_VARIABLE temp OUTPUT_STRIP_TRAILING_WHITESPACE)
|
execute_process(COMMAND grep CODENAME /etc/lsb-release OUTPUT_VARIABLE temp OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
execute_process(COMMAND dpkg --print-architecture OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
|
execute_process(COMMAND dpkg --print-architecture OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
@ -337,51 +367,55 @@ if(UNIX)
|
|||||||
endif(UNIX)
|
endif(UNIX)
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(CPACK_GENERATOR "Bundle")
|
|
||||||
set(CPACK_BUNDLE_NAME "Netgen")
|
|
||||||
set(CPACK_PACKAGE_FILE_NAME "netgen-${PACKAGE_VERSION}")
|
|
||||||
set(CPACK_BUNDLE_ICON ${CMAKE_CURRENT_SOURCE_DIR}/netgen.icns)
|
|
||||||
# set(CPACK_PACKAGE_ICON ${CMAKE_CURRENT_SOURCE_DIR}/netgen.icns)
|
|
||||||
|
|
||||||
# create some auxiliary files
|
# create some auxiliary files
|
||||||
set(mac_startup ${CMAKE_CURRENT_BINARY_DIR}/startup.sh)
|
set(mac_startup ${CMAKE_CURRENT_BINARY_DIR}/startup.sh)
|
||||||
file(WRITE ${mac_startup} "#!/bin/sh\n")
|
file(WRITE ${mac_startup} "\
|
||||||
file(APPEND ${mac_startup} "Netgen_BUNDLE=\"`echo \"$0\" | sed -e 's/\\/Contents\\/Resources\\/bin\\/startup.sh//'`\"\n")
|
#!/bin/sh
|
||||||
file(APPEND ${mac_startup} "Netgen_RESOURCES=\"$Netgen_BUNDLE/Contents/Resources\"\n")
|
Netgen_BUNDLE=\"`echo \"$0\" | sed -e 's/\\/Contents\\/MacOS\\/startup.sh//'`\"
|
||||||
file(APPEND ${mac_startup} "export DYLD_LIBRARY_PATH=$Netgen_RESOURCES/lib:$DYLD_LIBRARY_PATH\n")
|
Netgen_MACOS=\"$Netgen_BUNDLE/Contents/MacOS\"
|
||||||
file(APPEND ${mac_startup} "export NETGENDIR=$Netgen_RESOURCES/bin\n")
|
export NETGENDIR=$Netgen_MACOS
|
||||||
file(APPEND ${mac_startup} "cd $Netgen_RESOURCES\n")
|
export DYLD_LIBRARY_PATH=$Netgen_MACOS:$DYLD_LIBRARY_PATH
|
||||||
file(APPEND ${mac_startup} "$Netgen_RESOURCES/bin/netgen\n")
|
# export TIX_LIBRARY=$Netgen_MACOS/library
|
||||||
install(PROGRAMS ${mac_startup} DESTINATION bin)
|
# export TCLLIBPATH=$Netgen_MACOS:$TCLLIBPATH
|
||||||
|
export PYTHONPATH=$Netgen_BUNDLE/Contents/Resources/lib/python3.5/site-packages:$PYTHONPATH
|
||||||
|
cd $Netgen_MACOS
|
||||||
|
$Netgen_MACOS/netgen_main
|
||||||
|
")
|
||||||
|
install(PROGRAMS ${mac_startup} DESTINATION ${ng_install_dir_bin})
|
||||||
|
|
||||||
set(mac_ngsuite ${CMAKE_CURRENT_BINARY_DIR}/ngsuite.sh)
|
set(mac_ngsuite ${CMAKE_CURRENT_BINARY_DIR}/ngsuite.sh)
|
||||||
file(WRITE ${mac_ngsuite} "#!/bin/sh\n")
|
file(WRITE ${mac_ngsuite} "\
|
||||||
file(APPEND ${mac_ngsuite} "Netgen_BUNDLE=\"`echo \"$0\" | sed -e 's/\\/Contents\\/MacOS\\/Netgen//'`\"\n")
|
#!/bin/sh
|
||||||
file(APPEND ${mac_ngsuite} "Netgen_RESOURCES=\"$Netgen_BUNDLE/Contents/Resources\"\n")
|
Netgen_BUNDLE=\"`echo \"$0\" | sed -e 's/\\/Contents\\/MacOS\\/Netgen//'`\"
|
||||||
file(APPEND ${mac_ngsuite} "open -a /Applications/Utilities/Terminal.app $Netgen_RESOURCES/bin/startup.sh\n")
|
Netgen_MACOS=\"$Netgen_BUNDLE/Contents/MacOS\"
|
||||||
set(CPACK_BUNDLE_STARTUP_COMMAND ${mac_ngsuite})
|
open -a /Applications/Utilities/Terminal.app $Netgen_MACOS/startup.sh
|
||||||
|
")
|
||||||
|
install(PROGRAMS ${mac_ngsuite} DESTINATION ../MacOS RENAME Netgen)
|
||||||
|
|
||||||
set(mac_plist ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
|
set(mac_plist ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
|
||||||
file(WRITE ${mac_plist} "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
|
file(WRITE ${mac_plist} "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||||
file(APPEND ${mac_plist} "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n")
|
<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
|
||||||
file(APPEND ${mac_plist} "<plist version=\"1.0\">\n")
|
<plist version=\"1.0\">
|
||||||
file(APPEND ${mac_plist} "<dict>\n")
|
<dict>
|
||||||
file(APPEND ${mac_plist} " <key>CFBundleDevelopmentRegion</key>\n")
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
file(APPEND ${mac_plist} " <string>English</string>\n")
|
<string>English</string>
|
||||||
file(APPEND ${mac_plist} " <key>CFBundleExecutable</key>\n")
|
<key>CFBundleExecutable</key>
|
||||||
file(APPEND ${mac_plist} " <string>Netgen</string>\n")
|
<string>Netgen</string>
|
||||||
file(APPEND ${mac_plist} " <key>CFBundleIconFile</key>\n")
|
<key>CFBundleIconFile</key>
|
||||||
file(APPEND ${mac_plist} " <string>Netgen.icns</string>\n")
|
<string>Netgen.icns</string>
|
||||||
file(APPEND ${mac_plist} "</dict>\n")
|
<key>NSHighResolutionCapable</key>
|
||||||
file(APPEND ${mac_plist} "</plist>\n")
|
<string>True</string>
|
||||||
set(CPACK_BUNDLE_PLIST ${mac_plist})
|
</dict>
|
||||||
# set(CPACK_DMG_FORMAT "UDRW")
|
</plist>
|
||||||
# set(CPACK_DMG_DS_STORE .DS_Store_dmg)
|
")
|
||||||
# set(CPACK_DMG_BACKGROUND_IMAGE sculpture312.png)
|
install(FILES ${mac_plist} DESTINATION ../)
|
||||||
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/netgen.icns DESTINATION . RENAME Netgen.icns)
|
||||||
|
|
||||||
endif(APPLE)
|
endif(APPLE)
|
||||||
|
|
||||||
include(CPack)
|
if(NOT APPLE)
|
||||||
|
include(CPack)
|
||||||
|
endif()
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# uninstall target
|
# uninstall target
|
||||||
|
49
cmake_modules/netgen_fixup.cmake
Normal file
49
cmake_modules/netgen_fixup.cmake
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
include(BundleUtilities)
|
||||||
|
function(netgen_fixup_bundle app libs dirs)
|
||||||
|
message(STATUS "fixup_bundle")
|
||||||
|
message(STATUS " app='${app}'")
|
||||||
|
message(STATUS " libs='${libs}'")
|
||||||
|
message(STATUS " dirs='${dirs}'")
|
||||||
|
|
||||||
|
get_bundle_and_executable("${app}" bundle executable valid)
|
||||||
|
if(valid)
|
||||||
|
get_filename_component(exepath "${executable}" PATH)
|
||||||
|
|
||||||
|
message(STATUS "fixup_bundle: preparing...")
|
||||||
|
get_bundle_keys("${app}" "${libs}" "${dirs}" keys)
|
||||||
|
|
||||||
|
message(STATUS "fixup_bundle: copying...")
|
||||||
|
list(LENGTH keys n)
|
||||||
|
math(EXPR n ${n}*2)
|
||||||
|
|
||||||
|
set(i 0)
|
||||||
|
foreach(key ${keys})
|
||||||
|
math(EXPR i ${i}+1)
|
||||||
|
if(${${key}_COPYFLAG})
|
||||||
|
set(item "${${key}_ITEM}")
|
||||||
|
if(item MATCHES "[^/]+\\.framework/")
|
||||||
|
copy_resolved_framework_into_bundle("${${key}_RESOLVED_ITEM}"
|
||||||
|
"${${key}_RESOLVED_EMBEDDED_ITEM}")
|
||||||
|
else()
|
||||||
|
copy_resolved_item_into_bundle("${${key}_RESOLVED_ITEM}"
|
||||||
|
"${${key}_RESOLVED_EMBEDDED_ITEM}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
message(STATUS "fixup_bundle: fixing...")
|
||||||
|
foreach(key ${keys})
|
||||||
|
math(EXPR i ${i}+1)
|
||||||
|
message(STATUS "${i}/${n}: fixing up '${${key}_RESOLVED_EMBEDDED_ITEM}'")
|
||||||
|
fixup_bundle_item("${${key}_RESOLVED_EMBEDDED_ITEM}" "${exepath}" "${dirs}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
message(STATUS "fixup_bundle: cleaning up...")
|
||||||
|
clear_bundle_keys(keys)
|
||||||
|
|
||||||
|
else()
|
||||||
|
message(SEND_ERROR "error: fixup_bundle: not a valid bundle")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "fixup_bundle: done")
|
||||||
|
endfunction()
|
@ -14,7 +14,7 @@ endif(APPLE)
|
|||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
target_link_libraries(csg mesh ${PYTHON_LIBS})
|
target_link_libraries(csg mesh ${PYTHON_LIBS})
|
||||||
target_link_libraries(csg ${PYTHON_LIBS})
|
target_link_libraries(csg ${PYTHON_LIBS})
|
||||||
install( TARGETS csg DESTINATION lib COMPONENT netgen)
|
install( TARGETS csg ${ng_install_dir})
|
||||||
endif(NOT WIN32)
|
endif(NOT WIN32)
|
||||||
|
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ if(USE_GUI)
|
|||||||
if(APPLE)
|
if(APPLE)
|
||||||
set_target_properties( csgvis PROPERTIES SUFFIX ".so")
|
set_target_properties( csgvis PROPERTIES SUFFIX ".so")
|
||||||
endif(APPLE)
|
endif(APPLE)
|
||||||
install( TARGETS csgvis DESTINATION lib COMPONENT netgen)
|
install( TARGETS csgvis ${ng_install_dir})
|
||||||
endif(NOT WIN32)
|
endif(NOT WIN32)
|
||||||
endif(USE_GUI)
|
endif(USE_GUI)
|
||||||
|
|
||||||
|
@ -6,14 +6,14 @@ endif(APPLE)
|
|||||||
|
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
target_link_libraries(geom2d mesh ${PYTHON_LIBS})
|
target_link_libraries(geom2d mesh ${PYTHON_LIBS})
|
||||||
install( TARGETS geom2d DESTINATION lib COMPONENT netgen)
|
install( TARGETS geom2d ${ng_install_dir})
|
||||||
endif(NOT WIN32)
|
endif(NOT WIN32)
|
||||||
|
|
||||||
if(USE_GUI)
|
if(USE_GUI)
|
||||||
add_library(geom2dvis ${NG_LIB_TYPE} vsgeom2d.cpp)
|
add_library(geom2dvis ${NG_LIB_TYPE} vsgeom2d.cpp)
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
target_link_libraries(geom2dvis geom2d)
|
target_link_libraries(geom2dvis geom2d)
|
||||||
install( TARGETS geom2dvis DESTINATION lib COMPONENT netgen)
|
install( TARGETS geom2dvis ${ng_install_dir})
|
||||||
endif(NOT WIN32)
|
endif(NOT WIN32)
|
||||||
endif(USE_GUI)
|
endif(USE_GUI)
|
||||||
|
|
||||||
|
@ -20,6 +20,6 @@ if(NOT WIN32)
|
|||||||
if(USE_GUI)
|
if(USE_GUI)
|
||||||
target_link_libraries(interface visual)
|
target_link_libraries(interface visual)
|
||||||
endif(USE_GUI)
|
endif(USE_GUI)
|
||||||
install( TARGETS interface DESTINATION lib COMPONENT netgen )
|
install( TARGETS interface ${ng_install_dir})
|
||||||
endif(NOT WIN32)
|
endif(NOT WIN32)
|
||||||
|
|
||||||
|
@ -30,6 +30,6 @@ endif(APPLE)
|
|||||||
|
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
target_link_libraries( mesh ${ZLIB_LIBRARIES} ${MPI_CXX_LIBRARIES} ${PYTHON_LIBS} ${METIS_LIBRARY})
|
target_link_libraries( mesh ${ZLIB_LIBRARIES} ${MPI_CXX_LIBRARIES} ${PYTHON_LIBS} ${METIS_LIBRARY})
|
||||||
install( TARGETS mesh DESTINATION lib COMPONENT netgen )
|
install( TARGETS mesh ${ng_install_dir})
|
||||||
endif(NOT WIN32)
|
endif(NOT WIN32)
|
||||||
|
|
||||||
|
@ -5585,8 +5585,8 @@ namespace netgen
|
|||||||
bcnames[bcnr] = nullptr;
|
bcnames[bcnr] = nullptr;
|
||||||
|
|
||||||
for (auto & fd : facedecoding)
|
for (auto & fd : facedecoding)
|
||||||
if (fd.BCProperty() < bcnames.Size())
|
if (fd.BCProperty() <= bcnames.Size())
|
||||||
fd.SetBCName (bcnames[fd.BCProperty()]);
|
fd.SetBCName (bcnames[fd.BCProperty()-1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const string & Mesh ::GetBCName ( int bcnr ) const
|
const string & Mesh ::GetBCName ( int bcnr ) const
|
||||||
|
@ -9,6 +9,6 @@ add_library(occvis ${NG_LIB_TYPE} occpkg.cpp vsocc.cpp)
|
|||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
target_link_libraries( occ ${OCC_LIBRARIES} ${PYTHON_LIBS})
|
target_link_libraries( occ ${OCC_LIBRARIES} ${PYTHON_LIBS})
|
||||||
target_link_libraries( occvis occ )
|
target_link_libraries( occvis occ )
|
||||||
install( TARGETS occ occvis DESTINATION lib COMPONENT netgen )
|
install( TARGETS occ occvis ${ng_install_dir})
|
||||||
endif(NOT WIN32)
|
endif(NOT WIN32)
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ add_library(stl ${NG_LIB_TYPE}
|
|||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
target_link_libraries( stl mesh ${PYTHON_LIBS})
|
target_link_libraries( stl mesh ${PYTHON_LIBS})
|
||||||
target_link_libraries( stl ${PYTHON_LIBS})
|
target_link_libraries( stl ${PYTHON_LIBS})
|
||||||
install( TARGETS stl DESTINATION lib COMPONENT netgen )
|
install( TARGETS stl ${ng_install_dir})
|
||||||
endif(NOT WIN32)
|
endif(NOT WIN32)
|
||||||
|
|
||||||
if(USE_GUI)
|
if(USE_GUI)
|
||||||
@ -15,7 +15,7 @@ if(USE_GUI)
|
|||||||
)
|
)
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
target_link_libraries( stlvis stl )
|
target_link_libraries( stlvis stl )
|
||||||
install( TARGETS stlvis DESTINATION lib COMPONENT netgen )
|
install( TARGETS stlvis ${ng_install_dir})
|
||||||
endif(NOT WIN32)
|
endif(NOT WIN32)
|
||||||
endif(USE_GUI)
|
endif(USE_GUI)
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ add_library(visual ${NG_LIB_TYPE} ${LIB_VISUAL_SOURCES})
|
|||||||
|
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
target_link_libraries( visual ${PYTHON_LIBS} ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} ${TCL_LIBRARY} )
|
target_link_libraries( visual ${PYTHON_LIBS} ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} ${TCL_LIBRARY} )
|
||||||
install( TARGETS visual DESTINATION lib COMPONENT netgen )
|
install( TARGETS visual ${ng_install_dir})
|
||||||
endif(NOT WIN32)
|
endif(NOT WIN32)
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,6 +14,9 @@ if(USE_GUI)
|
|||||||
endif(NOT WIN32)
|
endif(NOT WIN32)
|
||||||
|
|
||||||
install(TARGETS netgen ${ng_install_dir})
|
install(TARGETS netgen ${ng_install_dir})
|
||||||
|
if(APPLE)
|
||||||
|
set_target_properties(netgen PROPERTIES OUTPUT_NAME netgen_main)
|
||||||
|
endif(APPLE)
|
||||||
|
|
||||||
endif(USE_GUI)
|
endif(USE_GUI)
|
||||||
|
|
||||||
@ -31,12 +34,16 @@ endif(USE_PYTHON)
|
|||||||
|
|
||||||
install(FILES
|
install(FILES
|
||||||
dialog.tcl menustat.tcl ngicon.tcl ng.tcl
|
dialog.tcl menustat.tcl ngicon.tcl ng.tcl
|
||||||
ngvisual.tcl sockets.tcl drawing.tcl nghelp.tcl ngshell.tcl
|
ngvisual.tcl sockets.tcl nghelp.tcl ngshell.tcl
|
||||||
ngtesting.tcl parameters.tcl variables.tcl csgeom.tcl stlgeom.tcl
|
ngtesting.tcl parameters.tcl variables.tcl csgeom.tcl stlgeom.tcl
|
||||||
occgeom.tcl acisgeom.tcl netgen.ocf
|
occgeom.tcl acisgeom.tcl netgen.ocf
|
||||||
DESTINATION bin COMPONENT netgen)
|
DESTINATION ${ng_install_dir_bin} COMPONENT netgen)
|
||||||
|
|
||||||
|
|
||||||
if(USE_GUI AND NOT WIN32)
|
if(USE_GUI AND NOT WIN32)
|
||||||
add_subdirectory(Togl-1.7)
|
add_subdirectory(Togl2.1)
|
||||||
|
install(FILES drawing.tcl DESTINATION ${ng_install_dir_bin} COMPONENT netgen)
|
||||||
|
else()
|
||||||
|
install(FILES drawing_togl17.tcl RENAME drawing.tcl DESTINATION ${ng_install_dir_bin} COMPONENT netgen)
|
||||||
endif(USE_GUI AND NOT WIN32)
|
endif(USE_GUI AND NOT WIN32)
|
||||||
|
|
||||||
|
17
ng/Togl2.1/CMakeLists.txt
Normal file
17
ng/Togl2.1/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
add_definitions("-DPACKAGE_NAME=\"Togl\" -DPACKAGE_TARNAME=\"togl\" -DPACKAGE_VERSION=\"2.1\" -DPACKAGE_STRING=\"Togl\ 2.1\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=0 -DHAVE_LIMITS_H=1 -DHAVE_SYS_PARAM_H=1 -DUSE_THREAD_ALLOC=1 -D_REENTRANT=1 -D_THREAD_SAFE=1 -DTCL_THREADS=1 -DMODULE_SCOPE=extern\ __attribute__\(\(__visibility__\(\"hidden\"\)\)\) -D_LARGEFILE64_SOURCE=1 -DTCL_WIDE_INT_IS_LONG=1 -DUSE_TCL_STUBS=1 -DUSE_TK_STUBS=1 -DAUTOSTEREOD=\"\"")
|
||||||
|
|
||||||
|
include_directories("${TCL_INCLUDE_PATH}/tcl-private/generic" "${TCL_INCLUDE_PATH}/tcl-private/unix")
|
||||||
|
include_directories("${TCL_INCLUDE_PATH}/tk-private/generic" "${TCL_INCLUDE_PATH}/tk-private/unix")
|
||||||
|
include_directories("${TCL_INCLUDE_PATH}/tk-private/generic/ttk")
|
||||||
|
include_directories("${TK_INCLUDE_PATH}/../PrivateHeaders")
|
||||||
|
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -fomit-frame-pointer -Wall -Wno-implicit-int")
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
set(CMAKE_C_COMPILER "gcc")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -x objective-c")
|
||||||
|
endif(APPLE)
|
||||||
|
|
||||||
|
add_library(togl togl.c toglProcAddr.c toglStubInit.c)
|
||||||
|
target_link_libraries(togl ${OPENGL_LIBRARIES} -ldl)
|
||||||
|
set_target_properties(togl PROPERTIES POSITION_INDEPENDENT_CODE ON )
|
8459
ng/Togl2.1/GL_unused/glext.h
Normal file
8459
ng/Togl2.1/GL_unused/glext.h
Normal file
File diff suppressed because it is too large
Load Diff
833
ng/Togl2.1/GL_unused/glxext.h
Normal file
833
ng/Togl2.1/GL_unused/glxext.h
Normal file
@ -0,0 +1,833 @@
|
|||||||
|
#ifndef __glxext_h_
|
||||||
|
#define __glxext_h_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Copyright (c) 2007 The Khronos Group Inc.
|
||||||
|
**
|
||||||
|
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
** copy of this software and/or associated documentation files (the
|
||||||
|
** "Materials"), to deal in the Materials without restriction, including
|
||||||
|
** without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
** distribute, sublicense, and/or sell copies of the Materials, and to
|
||||||
|
** permit persons to whom the Materials are 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 Materials.
|
||||||
|
**
|
||||||
|
** THE MATERIALS ARE 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 AUTHORS OR COPYRIGHT HOLDERS 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
|
||||||
|
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
|
||||||
|
#define WIN32_LEAN_AND_MEAN 1
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef APIENTRY
|
||||||
|
#define APIENTRY
|
||||||
|
#endif
|
||||||
|
#ifndef APIENTRYP
|
||||||
|
#define APIENTRYP APIENTRY *
|
||||||
|
#endif
|
||||||
|
#ifndef GLAPI
|
||||||
|
#define GLAPI extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*************************************************************/
|
||||||
|
|
||||||
|
/* Header file version number, required by OpenGL ABI for Linux */
|
||||||
|
/* glxext.h last updated 2008/10/22 */
|
||||||
|
/* Current version at http://www.opengl.org/registry/ */
|
||||||
|
#define GLX_GLXEXT_VERSION 21
|
||||||
|
|
||||||
|
#ifndef GLX_VERSION_1_3
|
||||||
|
#define GLX_WINDOW_BIT 0x00000001
|
||||||
|
#define GLX_PIXMAP_BIT 0x00000002
|
||||||
|
#define GLX_PBUFFER_BIT 0x00000004
|
||||||
|
#define GLX_RGBA_BIT 0x00000001
|
||||||
|
#define GLX_COLOR_INDEX_BIT 0x00000002
|
||||||
|
#define GLX_PBUFFER_CLOBBER_MASK 0x08000000
|
||||||
|
#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001
|
||||||
|
#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002
|
||||||
|
#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004
|
||||||
|
#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008
|
||||||
|
#define GLX_AUX_BUFFERS_BIT 0x00000010
|
||||||
|
#define GLX_DEPTH_BUFFER_BIT 0x00000020
|
||||||
|
#define GLX_STENCIL_BUFFER_BIT 0x00000040
|
||||||
|
#define GLX_ACCUM_BUFFER_BIT 0x00000080
|
||||||
|
#define GLX_CONFIG_CAVEAT 0x20
|
||||||
|
#define GLX_X_VISUAL_TYPE 0x22
|
||||||
|
#define GLX_TRANSPARENT_TYPE 0x23
|
||||||
|
#define GLX_TRANSPARENT_INDEX_VALUE 0x24
|
||||||
|
#define GLX_TRANSPARENT_RED_VALUE 0x25
|
||||||
|
#define GLX_TRANSPARENT_GREEN_VALUE 0x26
|
||||||
|
#define GLX_TRANSPARENT_BLUE_VALUE 0x27
|
||||||
|
#define GLX_TRANSPARENT_ALPHA_VALUE 0x28
|
||||||
|
#define GLX_DONT_CARE 0xFFFFFFFF
|
||||||
|
#define GLX_NONE 0x8000
|
||||||
|
#define GLX_SLOW_CONFIG 0x8001
|
||||||
|
#define GLX_TRUE_COLOR 0x8002
|
||||||
|
#define GLX_DIRECT_COLOR 0x8003
|
||||||
|
#define GLX_PSEUDO_COLOR 0x8004
|
||||||
|
#define GLX_STATIC_COLOR 0x8005
|
||||||
|
#define GLX_GRAY_SCALE 0x8006
|
||||||
|
#define GLX_STATIC_GRAY 0x8007
|
||||||
|
#define GLX_TRANSPARENT_RGB 0x8008
|
||||||
|
#define GLX_TRANSPARENT_INDEX 0x8009
|
||||||
|
#define GLX_VISUAL_ID 0x800B
|
||||||
|
#define GLX_SCREEN 0x800C
|
||||||
|
#define GLX_NON_CONFORMANT_CONFIG 0x800D
|
||||||
|
#define GLX_DRAWABLE_TYPE 0x8010
|
||||||
|
#define GLX_RENDER_TYPE 0x8011
|
||||||
|
#define GLX_X_RENDERABLE 0x8012
|
||||||
|
#define GLX_FBCONFIG_ID 0x8013
|
||||||
|
#define GLX_RGBA_TYPE 0x8014
|
||||||
|
#define GLX_COLOR_INDEX_TYPE 0x8015
|
||||||
|
#define GLX_MAX_PBUFFER_WIDTH 0x8016
|
||||||
|
#define GLX_MAX_PBUFFER_HEIGHT 0x8017
|
||||||
|
#define GLX_MAX_PBUFFER_PIXELS 0x8018
|
||||||
|
#define GLX_PRESERVED_CONTENTS 0x801B
|
||||||
|
#define GLX_LARGEST_PBUFFER 0x801C
|
||||||
|
#define GLX_WIDTH 0x801D
|
||||||
|
#define GLX_HEIGHT 0x801E
|
||||||
|
#define GLX_EVENT_MASK 0x801F
|
||||||
|
#define GLX_DAMAGED 0x8020
|
||||||
|
#define GLX_SAVED 0x8021
|
||||||
|
#define GLX_WINDOW 0x8022
|
||||||
|
#define GLX_PBUFFER 0x8023
|
||||||
|
#define GLX_PBUFFER_HEIGHT 0x8040
|
||||||
|
#define GLX_PBUFFER_WIDTH 0x8041
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_VERSION_1_4
|
||||||
|
#define GLX_SAMPLE_BUFFERS 100000
|
||||||
|
#define GLX_SAMPLES 100001
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_ARB_get_proc_address
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_ARB_multisample
|
||||||
|
#define GLX_SAMPLE_BUFFERS_ARB 100000
|
||||||
|
#define GLX_SAMPLES_ARB 100001
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_ARB_fbconfig_float
|
||||||
|
#define GLX_RGBA_FLOAT_TYPE_ARB 0x20B9
|
||||||
|
#define GLX_RGBA_FLOAT_BIT_ARB 0x00000004
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_ARB_create_context
|
||||||
|
#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001
|
||||||
|
#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
|
||||||
|
#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
||||||
|
#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
|
||||||
|
#define GLX_CONTEXT_FLAGS_ARB 0x2094
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIS_multisample
|
||||||
|
#define GLX_SAMPLE_BUFFERS_SGIS 100000
|
||||||
|
#define GLX_SAMPLES_SGIS 100001
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_EXT_visual_info
|
||||||
|
#define GLX_X_VISUAL_TYPE_EXT 0x22
|
||||||
|
#define GLX_TRANSPARENT_TYPE_EXT 0x23
|
||||||
|
#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24
|
||||||
|
#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25
|
||||||
|
#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26
|
||||||
|
#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27
|
||||||
|
#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28
|
||||||
|
#define GLX_NONE_EXT 0x8000
|
||||||
|
#define GLX_TRUE_COLOR_EXT 0x8002
|
||||||
|
#define GLX_DIRECT_COLOR_EXT 0x8003
|
||||||
|
#define GLX_PSEUDO_COLOR_EXT 0x8004
|
||||||
|
#define GLX_STATIC_COLOR_EXT 0x8005
|
||||||
|
#define GLX_GRAY_SCALE_EXT 0x8006
|
||||||
|
#define GLX_STATIC_GRAY_EXT 0x8007
|
||||||
|
#define GLX_TRANSPARENT_RGB_EXT 0x8008
|
||||||
|
#define GLX_TRANSPARENT_INDEX_EXT 0x8009
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGI_swap_control
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGI_video_sync
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGI_make_current_read
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIX_video_source
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_EXT_visual_rating
|
||||||
|
#define GLX_VISUAL_CAVEAT_EXT 0x20
|
||||||
|
#define GLX_SLOW_VISUAL_EXT 0x8001
|
||||||
|
#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D
|
||||||
|
/* reuse GLX_NONE_EXT */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_EXT_import_context
|
||||||
|
#define GLX_SHARE_CONTEXT_EXT 0x800A
|
||||||
|
#define GLX_VISUAL_ID_EXT 0x800B
|
||||||
|
#define GLX_SCREEN_EXT 0x800C
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIX_fbconfig
|
||||||
|
#define GLX_WINDOW_BIT_SGIX 0x00000001
|
||||||
|
#define GLX_PIXMAP_BIT_SGIX 0x00000002
|
||||||
|
#define GLX_RGBA_BIT_SGIX 0x00000001
|
||||||
|
#define GLX_COLOR_INDEX_BIT_SGIX 0x00000002
|
||||||
|
#define GLX_DRAWABLE_TYPE_SGIX 0x8010
|
||||||
|
#define GLX_RENDER_TYPE_SGIX 0x8011
|
||||||
|
#define GLX_X_RENDERABLE_SGIX 0x8012
|
||||||
|
#define GLX_FBCONFIG_ID_SGIX 0x8013
|
||||||
|
#define GLX_RGBA_TYPE_SGIX 0x8014
|
||||||
|
#define GLX_COLOR_INDEX_TYPE_SGIX 0x8015
|
||||||
|
/* reuse GLX_SCREEN_EXT */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIX_pbuffer
|
||||||
|
#define GLX_PBUFFER_BIT_SGIX 0x00000004
|
||||||
|
#define GLX_BUFFER_CLOBBER_MASK_SGIX 0x08000000
|
||||||
|
#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001
|
||||||
|
#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002
|
||||||
|
#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004
|
||||||
|
#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008
|
||||||
|
#define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010
|
||||||
|
#define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020
|
||||||
|
#define GLX_STENCIL_BUFFER_BIT_SGIX 0x00000040
|
||||||
|
#define GLX_ACCUM_BUFFER_BIT_SGIX 0x00000080
|
||||||
|
#define GLX_SAMPLE_BUFFERS_BIT_SGIX 0x00000100
|
||||||
|
#define GLX_MAX_PBUFFER_WIDTH_SGIX 0x8016
|
||||||
|
#define GLX_MAX_PBUFFER_HEIGHT_SGIX 0x8017
|
||||||
|
#define GLX_MAX_PBUFFER_PIXELS_SGIX 0x8018
|
||||||
|
#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019
|
||||||
|
#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A
|
||||||
|
#define GLX_PRESERVED_CONTENTS_SGIX 0x801B
|
||||||
|
#define GLX_LARGEST_PBUFFER_SGIX 0x801C
|
||||||
|
#define GLX_WIDTH_SGIX 0x801D
|
||||||
|
#define GLX_HEIGHT_SGIX 0x801E
|
||||||
|
#define GLX_EVENT_MASK_SGIX 0x801F
|
||||||
|
#define GLX_DAMAGED_SGIX 0x8020
|
||||||
|
#define GLX_SAVED_SGIX 0x8021
|
||||||
|
#define GLX_WINDOW_SGIX 0x8022
|
||||||
|
#define GLX_PBUFFER_SGIX 0x8023
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGI_cushion
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIX_video_resize
|
||||||
|
#define GLX_SYNC_FRAME_SGIX 0x00000000
|
||||||
|
#define GLX_SYNC_SWAP_SGIX 0x00000001
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIX_dmbuffer
|
||||||
|
#define GLX_DIGITAL_MEDIA_PBUFFER_SGIX 0x8024
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIX_swap_group
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIX_swap_barrier
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIS_blended_overlay
|
||||||
|
#define GLX_BLENDED_RGBA_SGIS 0x8025
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIS_shared_multisample
|
||||||
|
#define GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026
|
||||||
|
#define GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SUN_get_transparent_index
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_3DFX_multisample
|
||||||
|
#define GLX_SAMPLE_BUFFERS_3DFX 0x8050
|
||||||
|
#define GLX_SAMPLES_3DFX 0x8051
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_MESA_copy_sub_buffer
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_MESA_pixmap_colormap
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_MESA_release_buffers
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_MESA_set_3dfx_mode
|
||||||
|
#define GLX_3DFX_WINDOW_MODE_MESA 0x1
|
||||||
|
#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIX_visual_select_group
|
||||||
|
#define GLX_VISUAL_SELECT_GROUP_SGIX 0x8028
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_OML_swap_method
|
||||||
|
#define GLX_SWAP_METHOD_OML 0x8060
|
||||||
|
#define GLX_SWAP_EXCHANGE_OML 0x8061
|
||||||
|
#define GLX_SWAP_COPY_OML 0x8062
|
||||||
|
#define GLX_SWAP_UNDEFINED_OML 0x8063
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_OML_sync_control
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_NV_float_buffer
|
||||||
|
#define GLX_FLOAT_COMPONENTS_NV 0x20B0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIX_hyperpipe
|
||||||
|
#define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80
|
||||||
|
#define GLX_BAD_HYPERPIPE_CONFIG_SGIX 91
|
||||||
|
#define GLX_BAD_HYPERPIPE_SGIX 92
|
||||||
|
#define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX 0x00000001
|
||||||
|
#define GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002
|
||||||
|
#define GLX_PIPE_RECT_SGIX 0x00000001
|
||||||
|
#define GLX_PIPE_RECT_LIMITS_SGIX 0x00000002
|
||||||
|
#define GLX_HYPERPIPE_STEREO_SGIX 0x00000003
|
||||||
|
#define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX 0x00000004
|
||||||
|
#define GLX_HYPERPIPE_ID_SGIX 0x8030
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_MESA_agp_offset
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_EXT_fbconfig_packed_float
|
||||||
|
#define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT 0x20B1
|
||||||
|
#define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT 0x00000008
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_EXT_framebuffer_sRGB
|
||||||
|
#define GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20B2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_EXT_texture_from_pixmap
|
||||||
|
#define GLX_TEXTURE_1D_BIT_EXT 0x00000001
|
||||||
|
#define GLX_TEXTURE_2D_BIT_EXT 0x00000002
|
||||||
|
#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004
|
||||||
|
#define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0
|
||||||
|
#define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1
|
||||||
|
#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2
|
||||||
|
#define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3
|
||||||
|
#define GLX_Y_INVERTED_EXT 0x20D4
|
||||||
|
#define GLX_TEXTURE_FORMAT_EXT 0x20D5
|
||||||
|
#define GLX_TEXTURE_TARGET_EXT 0x20D6
|
||||||
|
#define GLX_MIPMAP_TEXTURE_EXT 0x20D7
|
||||||
|
#define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8
|
||||||
|
#define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9
|
||||||
|
#define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA
|
||||||
|
#define GLX_TEXTURE_1D_EXT 0x20DB
|
||||||
|
#define GLX_TEXTURE_2D_EXT 0x20DC
|
||||||
|
#define GLX_TEXTURE_RECTANGLE_EXT 0x20DD
|
||||||
|
#define GLX_FRONT_LEFT_EXT 0x20DE
|
||||||
|
#define GLX_FRONT_RIGHT_EXT 0x20DF
|
||||||
|
#define GLX_BACK_LEFT_EXT 0x20E0
|
||||||
|
#define GLX_BACK_RIGHT_EXT 0x20E1
|
||||||
|
#define GLX_FRONT_EXT GLX_FRONT_LEFT_EXT
|
||||||
|
#define GLX_BACK_EXT GLX_BACK_LEFT_EXT
|
||||||
|
#define GLX_AUX0_EXT 0x20E2
|
||||||
|
#define GLX_AUX1_EXT 0x20E3
|
||||||
|
#define GLX_AUX2_EXT 0x20E4
|
||||||
|
#define GLX_AUX3_EXT 0x20E5
|
||||||
|
#define GLX_AUX4_EXT 0x20E6
|
||||||
|
#define GLX_AUX5_EXT 0x20E7
|
||||||
|
#define GLX_AUX6_EXT 0x20E8
|
||||||
|
#define GLX_AUX7_EXT 0x20E9
|
||||||
|
#define GLX_AUX8_EXT 0x20EA
|
||||||
|
#define GLX_AUX9_EXT 0x20EB
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_NV_present_video
|
||||||
|
#define GLX_NUM_VIDEO_SLOTS_NV 0x20F0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_NV_video_out
|
||||||
|
#define GLX_VIDEO_OUT_COLOR_NV 0x20C3
|
||||||
|
#define GLX_VIDEO_OUT_ALPHA_NV 0x20C4
|
||||||
|
#define GLX_VIDEO_OUT_DEPTH_NV 0x20C5
|
||||||
|
#define GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6
|
||||||
|
#define GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7
|
||||||
|
#define GLX_VIDEO_OUT_FRAME_NV 0x20C8
|
||||||
|
#define GLX_VIDEO_OUT_FIELD_1_NV 0x20C9
|
||||||
|
#define GLX_VIDEO_OUT_FIELD_2_NV 0x20CA
|
||||||
|
#define GLX_VIDEO_OUT_STACKED_FIELDS_1_2_NV 0x20CB
|
||||||
|
#define GLX_VIDEO_OUT_STACKED_FIELDS_2_1_NV 0x20CC
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_NV_swap_group
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************/
|
||||||
|
|
||||||
|
#ifndef GLX_ARB_get_proc_address
|
||||||
|
typedef void (*__GLXextFuncPtr)(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIX_video_source
|
||||||
|
typedef XID GLXVideoSourceSGIX;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIX_fbconfig
|
||||||
|
typedef XID GLXFBConfigIDSGIX;
|
||||||
|
typedef struct __GLXFBConfigRec *GLXFBConfigSGIX;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIX_pbuffer
|
||||||
|
typedef XID GLXPbufferSGIX;
|
||||||
|
typedef struct {
|
||||||
|
int type;
|
||||||
|
unsigned long serial; /* # of last request processed by server */
|
||||||
|
Bool send_event; /* true if this came for SendEvent request */
|
||||||
|
Display *display; /* display the event was read from */
|
||||||
|
GLXDrawable drawable; /* i.d. of Drawable */
|
||||||
|
int event_type; /* GLX_DAMAGED_SGIX or GLX_SAVED_SGIX */
|
||||||
|
int draw_type; /* GLX_WINDOW_SGIX or GLX_PBUFFER_SGIX */
|
||||||
|
unsigned int mask; /* mask indicating which buffers are affected*/
|
||||||
|
int x, y;
|
||||||
|
int width, height;
|
||||||
|
int count; /* if nonzero, at least this many more */
|
||||||
|
} GLXBufferClobberEventSGIX;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLEXT_64_TYPES_DEFINED
|
||||||
|
/* This code block is duplicated in glext.h, so must be protected */
|
||||||
|
#define GLEXT_64_TYPES_DEFINED
|
||||||
|
/* Define int32_t, int64_t, and uint64_t types for UST/MSC */
|
||||||
|
/* (as used in the GLX_OML_sync_control extension). */
|
||||||
|
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||||
|
#include <inttypes.h>
|
||||||
|
#elif defined(__sun__) || defined(__digital__)
|
||||||
|
#include <inttypes.h>
|
||||||
|
#if defined(__STDC__)
|
||||||
|
#if defined(__arch64__) || defined(_LP64)
|
||||||
|
typedef long int int64_t;
|
||||||
|
typedef unsigned long int uint64_t;
|
||||||
|
#else
|
||||||
|
typedef long long int int64_t;
|
||||||
|
typedef unsigned long long int uint64_t;
|
||||||
|
#endif /* __arch64__ */
|
||||||
|
#endif /* __STDC__ */
|
||||||
|
#elif defined( __VMS ) || defined(__sgi)
|
||||||
|
#include <inttypes.h>
|
||||||
|
#elif defined(__SCO__) || defined(__USLC__)
|
||||||
|
#include <stdint.h>
|
||||||
|
#elif defined(__UNIXOS2__) || defined(__SOL64__)
|
||||||
|
typedef long int int32_t;
|
||||||
|
typedef long long int int64_t;
|
||||||
|
typedef unsigned long long int uint64_t;
|
||||||
|
#elif defined(_WIN32) && defined(__GNUC__)
|
||||||
|
#include <stdint.h>
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
typedef __int32 int32_t;
|
||||||
|
typedef __int64 int64_t;
|
||||||
|
typedef unsigned __int64 uint64_t;
|
||||||
|
#else
|
||||||
|
#include <inttypes.h> /* Fallback option */
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_VERSION_1_3
|
||||||
|
#define GLX_VERSION_1_3 1
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern GLXFBConfig * glXGetFBConfigs (Display *, int, int *);
|
||||||
|
extern GLXFBConfig * glXChooseFBConfig (Display *, int, const int *, int *);
|
||||||
|
extern int glXGetFBConfigAttrib (Display *, GLXFBConfig, int, int *);
|
||||||
|
extern XVisualInfo * glXGetVisualFromFBConfig (Display *, GLXFBConfig);
|
||||||
|
extern GLXWindow glXCreateWindow (Display *, GLXFBConfig, Window, const int *);
|
||||||
|
extern void glXDestroyWindow (Display *, GLXWindow);
|
||||||
|
extern GLXPixmap glXCreatePixmap (Display *, GLXFBConfig, Pixmap, const int *);
|
||||||
|
extern void glXDestroyPixmap (Display *, GLXPixmap);
|
||||||
|
extern GLXPbuffer glXCreatePbuffer (Display *, GLXFBConfig, const int *);
|
||||||
|
extern void glXDestroyPbuffer (Display *, GLXPbuffer);
|
||||||
|
extern void glXQueryDrawable (Display *, GLXDrawable, int, unsigned int *);
|
||||||
|
extern GLXContext glXCreateNewContext (Display *, GLXFBConfig, int, GLXContext, Bool);
|
||||||
|
extern Bool glXMakeContextCurrent (Display *, GLXDrawable, GLXDrawable, GLXContext);
|
||||||
|
extern GLXDrawable glXGetCurrentReadDrawable (void);
|
||||||
|
extern Display * glXGetCurrentDisplay (void);
|
||||||
|
extern int glXQueryContext (Display *, GLXContext, int, int *);
|
||||||
|
extern void glXSelectEvent (Display *, GLXDrawable, unsigned long);
|
||||||
|
extern void glXGetSelectedEvent (Display *, GLXDrawable, unsigned long *);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef GLXFBConfig * ( * PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements);
|
||||||
|
typedef GLXFBConfig * ( * PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);
|
||||||
|
typedef int ( * PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value);
|
||||||
|
typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config);
|
||||||
|
typedef GLXWindow ( * PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);
|
||||||
|
typedef void ( * PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win);
|
||||||
|
typedef GLXPixmap ( * PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);
|
||||||
|
typedef void ( * PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap);
|
||||||
|
typedef GLXPbuffer ( * PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list);
|
||||||
|
typedef void ( * PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf);
|
||||||
|
typedef void ( * PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
|
||||||
|
typedef GLXContext ( * PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);
|
||||||
|
typedef Bool ( * PFNGLXMAKECONTEXTCURRENTPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
|
||||||
|
typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLEPROC) (void);
|
||||||
|
typedef Display * ( * PFNGLXGETCURRENTDISPLAYPROC) (void);
|
||||||
|
typedef int ( * PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value);
|
||||||
|
typedef void ( * PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask);
|
||||||
|
typedef void ( * PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_VERSION_1_4
|
||||||
|
#define GLX_VERSION_1_4 1
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern __GLXextFuncPtr glXGetProcAddress (const GLubyte *);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_ARB_get_proc_address
|
||||||
|
#define GLX_ARB_get_proc_address 1
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSARBPROC) (const GLubyte *procName);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_ARB_multisample
|
||||||
|
#define GLX_ARB_multisample 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_ARB_fbconfig_float
|
||||||
|
#define GLX_ARB_fbconfig_float 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_ARB_create_context
|
||||||
|
#define GLX_ARB_create_context 1
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern GLXContext glXCreateContextAttribsARB (Display *, GLXFBConfig, GLXContext, Bool, const int *);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef GLXContext ( * PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIS_multisample
|
||||||
|
#define GLX_SGIS_multisample 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_EXT_visual_info
|
||||||
|
#define GLX_EXT_visual_info 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGI_swap_control
|
||||||
|
#define GLX_SGI_swap_control 1
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern int glXSwapIntervalSGI (int);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGI_video_sync
|
||||||
|
#define GLX_SGI_video_sync 1
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern int glXGetVideoSyncSGI (unsigned int *);
|
||||||
|
extern int glXWaitVideoSyncSGI (int, int, unsigned int *);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef int ( * PFNGLXGETVIDEOSYNCSGIPROC) (unsigned int *count);
|
||||||
|
typedef int ( * PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int *count);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGI_make_current_read
|
||||||
|
#define GLX_SGI_make_current_read 1
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern Bool glXMakeCurrentReadSGI (Display *, GLXDrawable, GLXDrawable, GLXContext);
|
||||||
|
extern GLXDrawable glXGetCurrentReadDrawableSGI (void);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef Bool ( * PFNGLXMAKECURRENTREADSGIPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
|
||||||
|
typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLESGIPROC) (void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIX_video_source
|
||||||
|
#define GLX_SGIX_video_source 1
|
||||||
|
#ifdef _VL_H
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern GLXVideoSourceSGIX glXCreateGLXVideoSourceSGIX (Display *, int, VLServer, VLPath, int, VLNode);
|
||||||
|
extern void glXDestroyGLXVideoSourceSGIX (Display *, GLXVideoSourceSGIX);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef GLXVideoSourceSGIX ( * PFNGLXCREATEGLXVIDEOSOURCESGIXPROC) (Display *display, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode);
|
||||||
|
typedef void ( * PFNGLXDESTROYGLXVIDEOSOURCESGIXPROC) (Display *dpy, GLXVideoSourceSGIX glxvideosource);
|
||||||
|
#endif /* _VL_H */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_EXT_visual_rating
|
||||||
|
#define GLX_EXT_visual_rating 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_EXT_import_context
|
||||||
|
#define GLX_EXT_import_context 1
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern Display * glXGetCurrentDisplayEXT (void);
|
||||||
|
extern int glXQueryContextInfoEXT (Display *, GLXContext, int, int *);
|
||||||
|
extern GLXContextID glXGetContextIDEXT (const GLXContext);
|
||||||
|
extern GLXContext glXImportContextEXT (Display *, GLXContextID);
|
||||||
|
extern void glXFreeContextEXT (Display *, GLXContext);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef Display * ( * PFNGLXGETCURRENTDISPLAYEXTPROC) (void);
|
||||||
|
typedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display *dpy, GLXContext context, int attribute, int *value);
|
||||||
|
typedef GLXContextID ( * PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context);
|
||||||
|
typedef GLXContext ( * PFNGLXIMPORTCONTEXTEXTPROC) (Display *dpy, GLXContextID contextID);
|
||||||
|
typedef void ( * PFNGLXFREECONTEXTEXTPROC) (Display *dpy, GLXContext context);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIX_fbconfig
|
||||||
|
#define GLX_SGIX_fbconfig 1
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern int glXGetFBConfigAttribSGIX (Display *, GLXFBConfigSGIX, int, int *);
|
||||||
|
extern GLXFBConfigSGIX * glXChooseFBConfigSGIX (Display *, int, int *, int *);
|
||||||
|
extern GLXPixmap glXCreateGLXPixmapWithConfigSGIX (Display *, GLXFBConfigSGIX, Pixmap);
|
||||||
|
extern GLXContext glXCreateContextWithConfigSGIX (Display *, GLXFBConfigSGIX, int, GLXContext, Bool);
|
||||||
|
extern XVisualInfo * glXGetVisualFromFBConfigSGIX (Display *, GLXFBConfigSGIX);
|
||||||
|
extern GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX (Display *, XVisualInfo *);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef int ( * PFNGLXGETFBCONFIGATTRIBSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value);
|
||||||
|
typedef GLXFBConfigSGIX * ( * PFNGLXCHOOSEFBCONFIGSGIXPROC) (Display *dpy, int screen, int *attrib_list, int *nelements);
|
||||||
|
typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap);
|
||||||
|
typedef GLXContext ( * PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct);
|
||||||
|
typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config);
|
||||||
|
typedef GLXFBConfigSGIX ( * PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display *dpy, XVisualInfo *vis);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIX_pbuffer
|
||||||
|
#define GLX_SGIX_pbuffer 1
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern GLXPbufferSGIX glXCreateGLXPbufferSGIX (Display *, GLXFBConfigSGIX, unsigned int, unsigned int, int *);
|
||||||
|
extern void glXDestroyGLXPbufferSGIX (Display *, GLXPbufferSGIX);
|
||||||
|
extern int glXQueryGLXPbufferSGIX (Display *, GLXPbufferSGIX, int, unsigned int *);
|
||||||
|
extern void glXSelectEventSGIX (Display *, GLXDrawable, unsigned long);
|
||||||
|
extern void glXGetSelectedEventSGIX (Display *, GLXDrawable, unsigned long *);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef GLXPbufferSGIX ( * PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list);
|
||||||
|
typedef void ( * PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf);
|
||||||
|
typedef int ( * PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value);
|
||||||
|
typedef void ( * PFNGLXSELECTEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long mask);
|
||||||
|
typedef void ( * PFNGLXGETSELECTEDEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long *mask);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGI_cushion
|
||||||
|
#define GLX_SGI_cushion 1
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern void glXCushionSGI (Display *, Window, float);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef void ( * PFNGLXCUSHIONSGIPROC) (Display *dpy, Window window, float cushion);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIX_video_resize
|
||||||
|
#define GLX_SGIX_video_resize 1
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern int glXBindChannelToWindowSGIX (Display *, int, int, Window);
|
||||||
|
extern int glXChannelRectSGIX (Display *, int, int, int, int, int, int);
|
||||||
|
extern int glXQueryChannelRectSGIX (Display *, int, int, int *, int *, int *, int *);
|
||||||
|
extern int glXQueryChannelDeltasSGIX (Display *, int, int, int *, int *, int *, int *);
|
||||||
|
extern int glXChannelRectSyncSGIX (Display *, int, int, GLenum);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef int ( * PFNGLXBINDCHANNELTOWINDOWSGIXPROC) (Display *display, int screen, int channel, Window window);
|
||||||
|
typedef int ( * PFNGLXCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int x, int y, int w, int h);
|
||||||
|
typedef int ( * PFNGLXQUERYCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int *dx, int *dy, int *dw, int *dh);
|
||||||
|
typedef int ( * PFNGLXQUERYCHANNELDELTASSGIXPROC) (Display *display, int screen, int channel, int *x, int *y, int *w, int *h);
|
||||||
|
typedef int ( * PFNGLXCHANNELRECTSYNCSGIXPROC) (Display *display, int screen, int channel, GLenum synctype);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIX_dmbuffer
|
||||||
|
#define GLX_SGIX_dmbuffer 1
|
||||||
|
#ifdef _DM_BUFFER_H_
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern Bool glXAssociateDMPbufferSGIX (Display *, GLXPbufferSGIX, DMparams *, DMbuffer);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef Bool ( * PFNGLXASSOCIATEDMPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer);
|
||||||
|
#endif /* _DM_BUFFER_H_ */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIX_swap_group
|
||||||
|
#define GLX_SGIX_swap_group 1
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern void glXJoinSwapGroupSGIX (Display *, GLXDrawable, GLXDrawable);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef void ( * PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIX_swap_barrier
|
||||||
|
#define GLX_SGIX_swap_barrier 1
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern void glXBindSwapBarrierSGIX (Display *, GLXDrawable, int);
|
||||||
|
extern Bool glXQueryMaxSwapBarriersSGIX (Display *, int, int *);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef void ( * PFNGLXBINDSWAPBARRIERSGIXPROC) (Display *dpy, GLXDrawable drawable, int barrier);
|
||||||
|
typedef Bool ( * PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC) (Display *dpy, int screen, int *max);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SUN_get_transparent_index
|
||||||
|
#define GLX_SUN_get_transparent_index 1
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern Status glXGetTransparentIndexSUN (Display *, Window, Window, long *);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef Status ( * PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_MESA_copy_sub_buffer
|
||||||
|
#define GLX_MESA_copy_sub_buffer 1
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern void glXCopySubBufferMESA (Display *, GLXDrawable, int, int, int, int);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef void ( * PFNGLXCOPYSUBBUFFERMESAPROC) (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_MESA_pixmap_colormap
|
||||||
|
#define GLX_MESA_pixmap_colormap 1
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern GLXPixmap glXCreateGLXPixmapMESA (Display *, XVisualInfo *, Pixmap, Colormap);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPMESAPROC) (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_MESA_release_buffers
|
||||||
|
#define GLX_MESA_release_buffers 1
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern Bool glXReleaseBuffersMESA (Display *, GLXDrawable);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef Bool ( * PFNGLXRELEASEBUFFERSMESAPROC) (Display *dpy, GLXDrawable drawable);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_MESA_set_3dfx_mode
|
||||||
|
#define GLX_MESA_set_3dfx_mode 1
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern Bool glXSet3DfxModeMESA (int);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef Bool ( * PFNGLXSET3DFXMODEMESAPROC) (int mode);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIX_visual_select_group
|
||||||
|
#define GLX_SGIX_visual_select_group 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_OML_swap_method
|
||||||
|
#define GLX_OML_swap_method 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_OML_sync_control
|
||||||
|
#define GLX_OML_sync_control 1
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern Bool glXGetSyncValuesOML (Display *, GLXDrawable, int64_t *, int64_t *, int64_t *);
|
||||||
|
extern Bool glXGetMscRateOML (Display *, GLXDrawable, int32_t *, int32_t *);
|
||||||
|
extern int64_t glXSwapBuffersMscOML (Display *, GLXDrawable, int64_t, int64_t, int64_t);
|
||||||
|
extern Bool glXWaitForMscOML (Display *, GLXDrawable, int64_t, int64_t, int64_t, int64_t *, int64_t *, int64_t *);
|
||||||
|
extern Bool glXWaitForSbcOML (Display *, GLXDrawable, int64_t, int64_t *, int64_t *, int64_t *);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef Bool ( * PFNGLXGETSYNCVALUESOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc);
|
||||||
|
typedef Bool ( * PFNGLXGETMSCRATEOMLPROC) (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator);
|
||||||
|
typedef int64_t ( * PFNGLXSWAPBUFFERSMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder);
|
||||||
|
typedef Bool ( * PFNGLXWAITFORMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc);
|
||||||
|
typedef Bool ( * PFNGLXWAITFORSBCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_NV_float_buffer
|
||||||
|
#define GLX_NV_float_buffer 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_SGIX_hyperpipe
|
||||||
|
#define GLX_SGIX_hyperpipe 1
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
|
||||||
|
int networkId;
|
||||||
|
} GLXHyperpipeNetworkSGIX;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
|
||||||
|
int channel;
|
||||||
|
unsigned int
|
||||||
|
participationType;
|
||||||
|
int timeSlice;
|
||||||
|
} GLXHyperpipeConfigSGIX;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
|
||||||
|
int srcXOrigin, srcYOrigin, srcWidth, srcHeight;
|
||||||
|
int destXOrigin, destYOrigin, destWidth, destHeight;
|
||||||
|
} GLXPipeRect;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
|
||||||
|
int XOrigin, YOrigin, maxHeight, maxWidth;
|
||||||
|
} GLXPipeRectLimits;
|
||||||
|
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern GLXHyperpipeNetworkSGIX * glXQueryHyperpipeNetworkSGIX (Display *, int *);
|
||||||
|
extern int glXHyperpipeConfigSGIX (Display *, int, int, GLXHyperpipeConfigSGIX *, int *);
|
||||||
|
extern GLXHyperpipeConfigSGIX * glXQueryHyperpipeConfigSGIX (Display *, int, int *);
|
||||||
|
extern int glXDestroyHyperpipeConfigSGIX (Display *, int);
|
||||||
|
extern int glXBindHyperpipeSGIX (Display *, int);
|
||||||
|
extern int glXQueryHyperpipeBestAttribSGIX (Display *, int, int, int, void *, void *);
|
||||||
|
extern int glXHyperpipeAttribSGIX (Display *, int, int, int, void *);
|
||||||
|
extern int glXQueryHyperpipeAttribSGIX (Display *, int, int, int, void *);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef GLXHyperpipeNetworkSGIX * ( * PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Display *dpy, int *npipes);
|
||||||
|
typedef int ( * PFNGLXHYPERPIPECONFIGSGIXPROC) (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId);
|
||||||
|
typedef GLXHyperpipeConfigSGIX * ( * PFNGLXQUERYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId, int *npipes);
|
||||||
|
typedef int ( * PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId);
|
||||||
|
typedef int ( * PFNGLXBINDHYPERPIPESGIXPROC) (Display *dpy, int hpId);
|
||||||
|
typedef int ( * PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList);
|
||||||
|
typedef int ( * PFNGLXHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList);
|
||||||
|
typedef int ( * PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_MESA_agp_offset
|
||||||
|
#define GLX_MESA_agp_offset 1
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern unsigned int glXGetAGPOffsetMESA (const void *);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef unsigned int ( * PFNGLXGETAGPOFFSETMESAPROC) (const void *pointer);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_EXT_fbconfig_packed_float
|
||||||
|
#define GLX_EXT_fbconfig_packed_float 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_EXT_framebuffer_sRGB
|
||||||
|
#define GLX_EXT_framebuffer_sRGB 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_EXT_texture_from_pixmap
|
||||||
|
#define GLX_EXT_texture_from_pixmap 1
|
||||||
|
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||||
|
extern void glXBindTexImageEXT (Display *, GLXDrawable, int, const int *);
|
||||||
|
extern void glXReleaseTexImageEXT (Display *, GLXDrawable, int);
|
||||||
|
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||||
|
typedef void ( * PFNGLXBINDTEXIMAGEEXTPROC) (Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list);
|
||||||
|
typedef void ( * PFNGLXRELEASETEXIMAGEEXTPROC) (Display *dpy, GLXDrawable drawable, int buffer);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_NV_present_video
|
||||||
|
#define GLX_NV_present_video 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_NV_video_out
|
||||||
|
#define GLX_NV_video_out 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLX_NV_swap_group
|
||||||
|
#define GLX_NV_swap_group 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
776
ng/Togl2.1/GL_unused/wglext.h
Normal file
776
ng/Togl2.1/GL_unused/wglext.h
Normal file
@ -0,0 +1,776 @@
|
|||||||
|
#ifndef __wglext_h_
|
||||||
|
#define __wglext_h_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Copyright (c) 2007 The Khronos Group Inc.
|
||||||
|
**
|
||||||
|
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
** copy of this software and/or associated documentation files (the
|
||||||
|
** "Materials"), to deal in the Materials without restriction, including
|
||||||
|
** without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
** distribute, sublicense, and/or sell copies of the Materials, and to
|
||||||
|
** permit persons to whom the Materials are 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 Materials.
|
||||||
|
**
|
||||||
|
** THE MATERIALS ARE 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 AUTHORS OR COPYRIGHT HOLDERS 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
|
||||||
|
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
|
||||||
|
#define WIN32_LEAN_AND_MEAN 1
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef APIENTRY
|
||||||
|
#define APIENTRY
|
||||||
|
#endif
|
||||||
|
#ifndef APIENTRYP
|
||||||
|
#define APIENTRYP APIENTRY *
|
||||||
|
#endif
|
||||||
|
#ifndef GLAPI
|
||||||
|
#define GLAPI extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*************************************************************/
|
||||||
|
|
||||||
|
/* Header file version number */
|
||||||
|
/* wglext.h last updated 2008/10/07 */
|
||||||
|
/* Current version at http://www.opengl.org/registry/ */
|
||||||
|
#define WGL_WGLEXT_VERSION 11
|
||||||
|
|
||||||
|
#ifndef WGL_ARB_buffer_region
|
||||||
|
#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001
|
||||||
|
#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002
|
||||||
|
#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004
|
||||||
|
#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_ARB_multisample
|
||||||
|
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
|
||||||
|
#define WGL_SAMPLES_ARB 0x2042
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_ARB_extensions_string
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_ARB_pixel_format
|
||||||
|
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
|
||||||
|
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
|
||||||
|
#define WGL_DRAW_TO_BITMAP_ARB 0x2002
|
||||||
|
#define WGL_ACCELERATION_ARB 0x2003
|
||||||
|
#define WGL_NEED_PALETTE_ARB 0x2004
|
||||||
|
#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
|
||||||
|
#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
|
||||||
|
#define WGL_SWAP_METHOD_ARB 0x2007
|
||||||
|
#define WGL_NUMBER_OVERLAYS_ARB 0x2008
|
||||||
|
#define WGL_NUMBER_UNDERLAYS_ARB 0x2009
|
||||||
|
#define WGL_TRANSPARENT_ARB 0x200A
|
||||||
|
#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
|
||||||
|
#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
|
||||||
|
#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
|
||||||
|
#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
|
||||||
|
#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
|
||||||
|
#define WGL_SHARE_DEPTH_ARB 0x200C
|
||||||
|
#define WGL_SHARE_STENCIL_ARB 0x200D
|
||||||
|
#define WGL_SHARE_ACCUM_ARB 0x200E
|
||||||
|
#define WGL_SUPPORT_GDI_ARB 0x200F
|
||||||
|
#define WGL_SUPPORT_OPENGL_ARB 0x2010
|
||||||
|
#define WGL_DOUBLE_BUFFER_ARB 0x2011
|
||||||
|
#define WGL_STEREO_ARB 0x2012
|
||||||
|
#define WGL_PIXEL_TYPE_ARB 0x2013
|
||||||
|
#define WGL_COLOR_BITS_ARB 0x2014
|
||||||
|
#define WGL_RED_BITS_ARB 0x2015
|
||||||
|
#define WGL_RED_SHIFT_ARB 0x2016
|
||||||
|
#define WGL_GREEN_BITS_ARB 0x2017
|
||||||
|
#define WGL_GREEN_SHIFT_ARB 0x2018
|
||||||
|
#define WGL_BLUE_BITS_ARB 0x2019
|
||||||
|
#define WGL_BLUE_SHIFT_ARB 0x201A
|
||||||
|
#define WGL_ALPHA_BITS_ARB 0x201B
|
||||||
|
#define WGL_ALPHA_SHIFT_ARB 0x201C
|
||||||
|
#define WGL_ACCUM_BITS_ARB 0x201D
|
||||||
|
#define WGL_ACCUM_RED_BITS_ARB 0x201E
|
||||||
|
#define WGL_ACCUM_GREEN_BITS_ARB 0x201F
|
||||||
|
#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
|
||||||
|
#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
|
||||||
|
#define WGL_DEPTH_BITS_ARB 0x2022
|
||||||
|
#define WGL_STENCIL_BITS_ARB 0x2023
|
||||||
|
#define WGL_AUX_BUFFERS_ARB 0x2024
|
||||||
|
#define WGL_NO_ACCELERATION_ARB 0x2025
|
||||||
|
#define WGL_GENERIC_ACCELERATION_ARB 0x2026
|
||||||
|
#define WGL_FULL_ACCELERATION_ARB 0x2027
|
||||||
|
#define WGL_SWAP_EXCHANGE_ARB 0x2028
|
||||||
|
#define WGL_SWAP_COPY_ARB 0x2029
|
||||||
|
#define WGL_SWAP_UNDEFINED_ARB 0x202A
|
||||||
|
#define WGL_TYPE_RGBA_ARB 0x202B
|
||||||
|
#define WGL_TYPE_COLORINDEX_ARB 0x202C
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_ARB_make_current_read
|
||||||
|
#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043
|
||||||
|
#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_ARB_pbuffer
|
||||||
|
#define WGL_DRAW_TO_PBUFFER_ARB 0x202D
|
||||||
|
#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E
|
||||||
|
#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F
|
||||||
|
#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030
|
||||||
|
#define WGL_PBUFFER_LARGEST_ARB 0x2033
|
||||||
|
#define WGL_PBUFFER_WIDTH_ARB 0x2034
|
||||||
|
#define WGL_PBUFFER_HEIGHT_ARB 0x2035
|
||||||
|
#define WGL_PBUFFER_LOST_ARB 0x2036
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_ARB_render_texture
|
||||||
|
#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070
|
||||||
|
#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071
|
||||||
|
#define WGL_TEXTURE_FORMAT_ARB 0x2072
|
||||||
|
#define WGL_TEXTURE_TARGET_ARB 0x2073
|
||||||
|
#define WGL_MIPMAP_TEXTURE_ARB 0x2074
|
||||||
|
#define WGL_TEXTURE_RGB_ARB 0x2075
|
||||||
|
#define WGL_TEXTURE_RGBA_ARB 0x2076
|
||||||
|
#define WGL_NO_TEXTURE_ARB 0x2077
|
||||||
|
#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078
|
||||||
|
#define WGL_TEXTURE_1D_ARB 0x2079
|
||||||
|
#define WGL_TEXTURE_2D_ARB 0x207A
|
||||||
|
#define WGL_MIPMAP_LEVEL_ARB 0x207B
|
||||||
|
#define WGL_CUBE_MAP_FACE_ARB 0x207C
|
||||||
|
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D
|
||||||
|
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E
|
||||||
|
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F
|
||||||
|
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080
|
||||||
|
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081
|
||||||
|
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082
|
||||||
|
#define WGL_FRONT_LEFT_ARB 0x2083
|
||||||
|
#define WGL_FRONT_RIGHT_ARB 0x2084
|
||||||
|
#define WGL_BACK_LEFT_ARB 0x2085
|
||||||
|
#define WGL_BACK_RIGHT_ARB 0x2086
|
||||||
|
#define WGL_AUX0_ARB 0x2087
|
||||||
|
#define WGL_AUX1_ARB 0x2088
|
||||||
|
#define WGL_AUX2_ARB 0x2089
|
||||||
|
#define WGL_AUX3_ARB 0x208A
|
||||||
|
#define WGL_AUX4_ARB 0x208B
|
||||||
|
#define WGL_AUX5_ARB 0x208C
|
||||||
|
#define WGL_AUX6_ARB 0x208D
|
||||||
|
#define WGL_AUX7_ARB 0x208E
|
||||||
|
#define WGL_AUX8_ARB 0x208F
|
||||||
|
#define WGL_AUX9_ARB 0x2090
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_ARB_pixel_format_float
|
||||||
|
#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_ARB_create_context
|
||||||
|
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001
|
||||||
|
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002
|
||||||
|
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
||||||
|
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
|
||||||
|
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
|
||||||
|
#define WGL_CONTEXT_FLAGS_ARB 0x2094
|
||||||
|
#define ERROR_INVALID_VERSION_ARB 0x2095
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_EXT_make_current_read
|
||||||
|
#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_EXT_pixel_format
|
||||||
|
#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000
|
||||||
|
#define WGL_DRAW_TO_WINDOW_EXT 0x2001
|
||||||
|
#define WGL_DRAW_TO_BITMAP_EXT 0x2002
|
||||||
|
#define WGL_ACCELERATION_EXT 0x2003
|
||||||
|
#define WGL_NEED_PALETTE_EXT 0x2004
|
||||||
|
#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005
|
||||||
|
#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006
|
||||||
|
#define WGL_SWAP_METHOD_EXT 0x2007
|
||||||
|
#define WGL_NUMBER_OVERLAYS_EXT 0x2008
|
||||||
|
#define WGL_NUMBER_UNDERLAYS_EXT 0x2009
|
||||||
|
#define WGL_TRANSPARENT_EXT 0x200A
|
||||||
|
#define WGL_TRANSPARENT_VALUE_EXT 0x200B
|
||||||
|
#define WGL_SHARE_DEPTH_EXT 0x200C
|
||||||
|
#define WGL_SHARE_STENCIL_EXT 0x200D
|
||||||
|
#define WGL_SHARE_ACCUM_EXT 0x200E
|
||||||
|
#define WGL_SUPPORT_GDI_EXT 0x200F
|
||||||
|
#define WGL_SUPPORT_OPENGL_EXT 0x2010
|
||||||
|
#define WGL_DOUBLE_BUFFER_EXT 0x2011
|
||||||
|
#define WGL_STEREO_EXT 0x2012
|
||||||
|
#define WGL_PIXEL_TYPE_EXT 0x2013
|
||||||
|
#define WGL_COLOR_BITS_EXT 0x2014
|
||||||
|
#define WGL_RED_BITS_EXT 0x2015
|
||||||
|
#define WGL_RED_SHIFT_EXT 0x2016
|
||||||
|
#define WGL_GREEN_BITS_EXT 0x2017
|
||||||
|
#define WGL_GREEN_SHIFT_EXT 0x2018
|
||||||
|
#define WGL_BLUE_BITS_EXT 0x2019
|
||||||
|
#define WGL_BLUE_SHIFT_EXT 0x201A
|
||||||
|
#define WGL_ALPHA_BITS_EXT 0x201B
|
||||||
|
#define WGL_ALPHA_SHIFT_EXT 0x201C
|
||||||
|
#define WGL_ACCUM_BITS_EXT 0x201D
|
||||||
|
#define WGL_ACCUM_RED_BITS_EXT 0x201E
|
||||||
|
#define WGL_ACCUM_GREEN_BITS_EXT 0x201F
|
||||||
|
#define WGL_ACCUM_BLUE_BITS_EXT 0x2020
|
||||||
|
#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021
|
||||||
|
#define WGL_DEPTH_BITS_EXT 0x2022
|
||||||
|
#define WGL_STENCIL_BITS_EXT 0x2023
|
||||||
|
#define WGL_AUX_BUFFERS_EXT 0x2024
|
||||||
|
#define WGL_NO_ACCELERATION_EXT 0x2025
|
||||||
|
#define WGL_GENERIC_ACCELERATION_EXT 0x2026
|
||||||
|
#define WGL_FULL_ACCELERATION_EXT 0x2027
|
||||||
|
#define WGL_SWAP_EXCHANGE_EXT 0x2028
|
||||||
|
#define WGL_SWAP_COPY_EXT 0x2029
|
||||||
|
#define WGL_SWAP_UNDEFINED_EXT 0x202A
|
||||||
|
#define WGL_TYPE_RGBA_EXT 0x202B
|
||||||
|
#define WGL_TYPE_COLORINDEX_EXT 0x202C
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_EXT_pbuffer
|
||||||
|
#define WGL_DRAW_TO_PBUFFER_EXT 0x202D
|
||||||
|
#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E
|
||||||
|
#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F
|
||||||
|
#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030
|
||||||
|
#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031
|
||||||
|
#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032
|
||||||
|
#define WGL_PBUFFER_LARGEST_EXT 0x2033
|
||||||
|
#define WGL_PBUFFER_WIDTH_EXT 0x2034
|
||||||
|
#define WGL_PBUFFER_HEIGHT_EXT 0x2035
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_EXT_depth_float
|
||||||
|
#define WGL_DEPTH_FLOAT_EXT 0x2040
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_3DFX_multisample
|
||||||
|
#define WGL_SAMPLE_BUFFERS_3DFX 0x2060
|
||||||
|
#define WGL_SAMPLES_3DFX 0x2061
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_EXT_multisample
|
||||||
|
#define WGL_SAMPLE_BUFFERS_EXT 0x2041
|
||||||
|
#define WGL_SAMPLES_EXT 0x2042
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_I3D_digital_video_control
|
||||||
|
#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050
|
||||||
|
#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051
|
||||||
|
#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052
|
||||||
|
#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_I3D_gamma
|
||||||
|
#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E
|
||||||
|
#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_I3D_genlock
|
||||||
|
#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044
|
||||||
|
#define WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D 0x2045
|
||||||
|
#define WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D 0x2046
|
||||||
|
#define WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D 0x2047
|
||||||
|
#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048
|
||||||
|
#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049
|
||||||
|
#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A
|
||||||
|
#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B
|
||||||
|
#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_I3D_image_buffer
|
||||||
|
#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001
|
||||||
|
#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_I3D_swap_frame_lock
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_NV_render_depth_texture
|
||||||
|
#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3
|
||||||
|
#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4
|
||||||
|
#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5
|
||||||
|
#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6
|
||||||
|
#define WGL_DEPTH_COMPONENT_NV 0x20A7
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_NV_render_texture_rectangle
|
||||||
|
#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0
|
||||||
|
#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1
|
||||||
|
#define WGL_TEXTURE_RECTANGLE_NV 0x20A2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_ATI_pixel_format_float
|
||||||
|
#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_NV_float_buffer
|
||||||
|
#define WGL_FLOAT_COMPONENTS_NV 0x20B0
|
||||||
|
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1
|
||||||
|
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2
|
||||||
|
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3
|
||||||
|
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4
|
||||||
|
#define WGL_TEXTURE_FLOAT_R_NV 0x20B5
|
||||||
|
#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6
|
||||||
|
#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7
|
||||||
|
#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_3DL_stereo_control
|
||||||
|
#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055
|
||||||
|
#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056
|
||||||
|
#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057
|
||||||
|
#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_EXT_pixel_format_packed_float
|
||||||
|
#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_EXT_framebuffer_sRGB
|
||||||
|
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_NV_present_video
|
||||||
|
#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_NV_video_out
|
||||||
|
#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0
|
||||||
|
#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1
|
||||||
|
#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2
|
||||||
|
#define WGL_VIDEO_OUT_COLOR_NV 0x20C3
|
||||||
|
#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4
|
||||||
|
#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5
|
||||||
|
#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6
|
||||||
|
#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7
|
||||||
|
#define WGL_VIDEO_OUT_FRAME 0x20C8
|
||||||
|
#define WGL_VIDEO_OUT_FIELD_1 0x20C9
|
||||||
|
#define WGL_VIDEO_OUT_FIELD_2 0x20CA
|
||||||
|
#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB
|
||||||
|
#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_NV_swap_group
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_NV_gpu_affinity
|
||||||
|
#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0
|
||||||
|
#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************/
|
||||||
|
|
||||||
|
#ifndef WGL_ARB_pbuffer
|
||||||
|
DECLARE_HANDLE(HPBUFFERARB);
|
||||||
|
#endif
|
||||||
|
#ifndef WGL_EXT_pbuffer
|
||||||
|
DECLARE_HANDLE(HPBUFFEREXT);
|
||||||
|
#endif
|
||||||
|
#ifndef WGL_NV_present_video
|
||||||
|
DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);
|
||||||
|
#endif
|
||||||
|
#ifndef WGL_NV_video_out
|
||||||
|
DECLARE_HANDLE(HPVIDEODEV);
|
||||||
|
#endif
|
||||||
|
#ifndef WGL_NV_gpu_affinity
|
||||||
|
DECLARE_HANDLE(HPGPUNV);
|
||||||
|
DECLARE_HANDLE(HGPUNV);
|
||||||
|
|
||||||
|
typedef struct _GPU_DEVICE {
|
||||||
|
DWORD cb;
|
||||||
|
CHAR DeviceName[32];
|
||||||
|
CHAR DeviceString[128];
|
||||||
|
DWORD Flags;
|
||||||
|
RECT rcVirtualScreen;
|
||||||
|
} GPU_DEVICE, *PGPU_DEVICE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_ARB_buffer_region
|
||||||
|
#define WGL_ARB_buffer_region 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern HANDLE WINAPI wglCreateBufferRegionARB (HDC, int, UINT);
|
||||||
|
extern VOID WINAPI wglDeleteBufferRegionARB (HANDLE);
|
||||||
|
extern BOOL WINAPI wglSaveBufferRegionARB (HANDLE, int, int, int, int);
|
||||||
|
extern BOOL WINAPI wglRestoreBufferRegionARB (HANDLE, int, int, int, int, int, int);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType);
|
||||||
|
typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_ARB_multisample
|
||||||
|
#define WGL_ARB_multisample 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_ARB_extensions_string
|
||||||
|
#define WGL_ARB_extensions_string 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern const char * WINAPI wglGetExtensionsStringARB (HDC);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_ARB_pixel_format
|
||||||
|
#define WGL_ARB_pixel_format 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern BOOL WINAPI wglGetPixelFormatAttribivARB (HDC, int, int, UINT, const int *, int *);
|
||||||
|
extern BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC, int, int, UINT, const int *, FLOAT *);
|
||||||
|
extern BOOL WINAPI wglChoosePixelFormatARB (HDC, const int *, const FLOAT *, UINT, int *, UINT *);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_ARB_make_current_read
|
||||||
|
#define WGL_ARB_make_current_read 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern BOOL WINAPI wglMakeContextCurrentARB (HDC, HDC, HGLRC);
|
||||||
|
extern HDC WINAPI wglGetCurrentReadDCARB (void);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
|
||||||
|
typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_ARB_pbuffer
|
||||||
|
#define WGL_ARB_pbuffer 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern HPBUFFERARB WINAPI wglCreatePbufferARB (HDC, int, int, int, const int *);
|
||||||
|
extern HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB);
|
||||||
|
extern int WINAPI wglReleasePbufferDCARB (HPBUFFERARB, HDC);
|
||||||
|
extern BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB);
|
||||||
|
extern BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB, int, int *);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
|
||||||
|
typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer);
|
||||||
|
typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_ARB_render_texture
|
||||||
|
#define WGL_ARB_render_texture 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern BOOL WINAPI wglBindTexImageARB (HPBUFFERARB, int);
|
||||||
|
extern BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB, int);
|
||||||
|
extern BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB, const int *);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_ARB_pixel_format_float
|
||||||
|
#define WGL_ARB_pixel_format_float 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_ARB_create_context
|
||||||
|
#define WGL_ARB_create_context 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern HGLRC WINAPI wglCreateContextAttribsARB (HDC, HGLRC, const int *);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_EXT_display_color_table
|
||||||
|
#define WGL_EXT_display_color_table 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort);
|
||||||
|
extern GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *, GLuint);
|
||||||
|
extern GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort);
|
||||||
|
extern VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id);
|
||||||
|
typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length);
|
||||||
|
typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id);
|
||||||
|
typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_EXT_extensions_string
|
||||||
|
#define WGL_EXT_extensions_string 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern const char * WINAPI wglGetExtensionsStringEXT (void);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_EXT_make_current_read
|
||||||
|
#define WGL_EXT_make_current_read 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern BOOL WINAPI wglMakeContextCurrentEXT (HDC, HDC, HGLRC);
|
||||||
|
extern HDC WINAPI wglGetCurrentReadDCEXT (void);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
|
||||||
|
typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_EXT_pbuffer
|
||||||
|
#define WGL_EXT_pbuffer 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC, int, int, int, const int *);
|
||||||
|
extern HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT);
|
||||||
|
extern int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT, HDC);
|
||||||
|
extern BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT);
|
||||||
|
extern BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT, int, int *);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
|
||||||
|
typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer);
|
||||||
|
typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_EXT_pixel_format
|
||||||
|
#define WGL_EXT_pixel_format 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC, int, int, UINT, int *, int *);
|
||||||
|
extern BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC, int, int, UINT, int *, FLOAT *);
|
||||||
|
extern BOOL WINAPI wglChoosePixelFormatEXT (HDC, const int *, const FLOAT *, UINT, int *, UINT *);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_EXT_swap_control
|
||||||
|
#define WGL_EXT_swap_control 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern BOOL WINAPI wglSwapIntervalEXT (int);
|
||||||
|
extern int WINAPI wglGetSwapIntervalEXT (void);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval);
|
||||||
|
typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_EXT_depth_float
|
||||||
|
#define WGL_EXT_depth_float 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_NV_vertex_array_range
|
||||||
|
#define WGL_NV_vertex_array_range 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern void* WINAPI wglAllocateMemoryNV (GLsizei, GLfloat, GLfloat, GLfloat);
|
||||||
|
extern void WINAPI wglFreeMemoryNV (void *);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef void* (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
|
||||||
|
typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_3DFX_multisample
|
||||||
|
#define WGL_3DFX_multisample 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_EXT_multisample
|
||||||
|
#define WGL_EXT_multisample 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_OML_sync_control
|
||||||
|
#define WGL_OML_sync_control 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern BOOL WINAPI wglGetSyncValuesOML (HDC, INT64 *, INT64 *, INT64 *);
|
||||||
|
extern BOOL WINAPI wglGetMscRateOML (HDC, INT32 *, INT32 *);
|
||||||
|
extern INT64 WINAPI wglSwapBuffersMscOML (HDC, INT64, INT64, INT64);
|
||||||
|
extern INT64 WINAPI wglSwapLayerBuffersMscOML (HDC, int, INT64, INT64, INT64);
|
||||||
|
extern BOOL WINAPI wglWaitForMscOML (HDC, INT64, INT64, INT64, INT64 *, INT64 *, INT64 *);
|
||||||
|
extern BOOL WINAPI wglWaitForSbcOML (HDC, INT64, INT64 *, INT64 *, INT64 *);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator);
|
||||||
|
typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);
|
||||||
|
typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_I3D_digital_video_control
|
||||||
|
#define WGL_I3D_digital_video_control 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC, int, int *);
|
||||||
|
extern BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC, int, const int *);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_I3D_gamma
|
||||||
|
#define WGL_I3D_gamma 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern BOOL WINAPI wglGetGammaTableParametersI3D (HDC, int, int *);
|
||||||
|
extern BOOL WINAPI wglSetGammaTableParametersI3D (HDC, int, const int *);
|
||||||
|
extern BOOL WINAPI wglGetGammaTableI3D (HDC, int, USHORT *, USHORT *, USHORT *);
|
||||||
|
extern BOOL WINAPI wglSetGammaTableI3D (HDC, int, const USHORT *, const USHORT *, const USHORT *);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_I3D_genlock
|
||||||
|
#define WGL_I3D_genlock 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern BOOL WINAPI wglEnableGenlockI3D (HDC);
|
||||||
|
extern BOOL WINAPI wglDisableGenlockI3D (HDC);
|
||||||
|
extern BOOL WINAPI wglIsEnabledGenlockI3D (HDC, BOOL *);
|
||||||
|
extern BOOL WINAPI wglGenlockSourceI3D (HDC, UINT);
|
||||||
|
extern BOOL WINAPI wglGetGenlockSourceI3D (HDC, UINT *);
|
||||||
|
extern BOOL WINAPI wglGenlockSourceEdgeI3D (HDC, UINT);
|
||||||
|
extern BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC, UINT *);
|
||||||
|
extern BOOL WINAPI wglGenlockSampleRateI3D (HDC, UINT);
|
||||||
|
extern BOOL WINAPI wglGetGenlockSampleRateI3D (HDC, UINT *);
|
||||||
|
extern BOOL WINAPI wglGenlockSourceDelayI3D (HDC, UINT);
|
||||||
|
extern BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC, UINT *);
|
||||||
|
extern BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC, UINT *, UINT *);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_I3D_image_buffer
|
||||||
|
#define WGL_I3D_image_buffer 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern LPVOID WINAPI wglCreateImageBufferI3D (HDC, DWORD, UINT);
|
||||||
|
extern BOOL WINAPI wglDestroyImageBufferI3D (HDC, LPVOID);
|
||||||
|
extern BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC, const HANDLE *, const LPVOID *, const DWORD *, UINT);
|
||||||
|
extern BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC, const LPVOID *, UINT);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_I3D_swap_frame_lock
|
||||||
|
#define WGL_I3D_swap_frame_lock 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern BOOL WINAPI wglEnableFrameLockI3D (void);
|
||||||
|
extern BOOL WINAPI wglDisableFrameLockI3D (void);
|
||||||
|
extern BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *);
|
||||||
|
extern BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_I3D_swap_frame_usage
|
||||||
|
#define WGL_I3D_swap_frame_usage 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern BOOL WINAPI wglGetFrameUsageI3D (float *);
|
||||||
|
extern BOOL WINAPI wglBeginFrameTrackingI3D (void);
|
||||||
|
extern BOOL WINAPI wglEndFrameTrackingI3D (void);
|
||||||
|
extern BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *, DWORD *, float *);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_ATI_pixel_format_float
|
||||||
|
#define WGL_ATI_pixel_format_float 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_NV_float_buffer
|
||||||
|
#define WGL_NV_float_buffer 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_EXT_pixel_format_packed_float
|
||||||
|
#define WGL_EXT_pixel_format_packed_float 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_EXT_framebuffer_sRGB
|
||||||
|
#define WGL_EXT_framebuffer_sRGB 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_NV_present_video
|
||||||
|
#define WGL_NV_present_video 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern int WINAPI wglEnumerateVideoDevicesNV (HDC, HVIDEOOUTPUTDEVICENV *);
|
||||||
|
extern BOOL WINAPI wglBindVideoDeviceNV (HDC, unsigned int, HVIDEOOUTPUTDEVICENV, const int *);
|
||||||
|
extern BOOL WINAPI wglQueryCurrentContextNV (int, int *);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_NV_video_out
|
||||||
|
#define WGL_NV_video_out 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern BOOL WINAPI wglGetVideoDeviceNV (HDC, int, HPVIDEODEV *);
|
||||||
|
extern BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV);
|
||||||
|
extern BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV, HPBUFFERARB, int);
|
||||||
|
extern BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB, int);
|
||||||
|
extern BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB, int, unsigned long *, BOOL);
|
||||||
|
extern BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV, unsigned long *, unsigned long *);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_NV_swap_group
|
||||||
|
#define WGL_NV_swap_group 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern BOOL WINAPI wglJoinSwapGroupNV (HDC, GLuint);
|
||||||
|
extern BOOL WINAPI wglBindSwapBarrierNV (GLuint, GLuint);
|
||||||
|
extern BOOL WINAPI wglQuerySwapGroupNV (HDC, GLuint *, GLuint *);
|
||||||
|
extern BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC, GLuint *, GLuint *);
|
||||||
|
extern BOOL WINAPI wglQueryFrameCountNV (HDC, GLuint *);
|
||||||
|
extern BOOL WINAPI wglResetFrameCountNV (HDC);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WGL_NV_gpu_affinity
|
||||||
|
#define WGL_NV_gpu_affinity 1
|
||||||
|
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||||
|
extern BOOL WINAPI wglEnumGpusNV (UINT, HGPUNV *);
|
||||||
|
extern BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV, UINT, PGPU_DEVICE);
|
||||||
|
extern HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *);
|
||||||
|
extern BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC, UINT, HGPUNV *);
|
||||||
|
extern BOOL WINAPI wglDeleteDCNV (HDC);
|
||||||
|
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||||
|
typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);
|
||||||
|
typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
28
ng/Togl2.1/LICENSE
Normal file
28
ng/Togl2.1/LICENSE
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
This software is copyrighted by Brian Paul (brian@mesa3d.org),
|
||||||
|
Benjamin Bederson (bederson@cs.umd.edu), and Greg Couch
|
||||||
|
(gregcouch@users.sourceforge.net). The following terms apply to all
|
||||||
|
files associated with the software unless explicitly disclaimed in
|
||||||
|
individual files.
|
||||||
|
|
||||||
|
The authors hereby grant permission to use, copy, modify, distribute,
|
||||||
|
and license this software and its documentation for any purpose, provided
|
||||||
|
that existing copyright notices are retained in all copies and that this
|
||||||
|
notice is included verbatim in any distributions. No written agreement,
|
||||||
|
license, or royalty fee is required for any of the authorized uses.
|
||||||
|
Modifications to this software may be copyrighted by their authors
|
||||||
|
and need not follow the licensing terms described here, provided that
|
||||||
|
the new terms are clearly indicated on the first page of each file where
|
||||||
|
they apply.
|
||||||
|
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
|
||||||
|
FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
||||||
|
ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
|
||||||
|
DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
|
||||||
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
|
||||||
|
IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
|
||||||
|
NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
|
||||||
|
MODIFICATIONS.
|
572
ng/Togl2.1/Makefile.in
Normal file
572
ng/Togl2.1/Makefile.in
Normal file
@ -0,0 +1,572 @@
|
|||||||
|
# Makefile.in --
|
||||||
|
#
|
||||||
|
# This file is a Makefile for Sample TEA Extension. If it has the name
|
||||||
|
# "Makefile.in" then it is a template for a Makefile; to generate the
|
||||||
|
# actual Makefile, run "./configure", which is a configuration script
|
||||||
|
# generated by the "autoconf" program (constructs like "@foo@" will get
|
||||||
|
# replaced in the actual Makefile.
|
||||||
|
#
|
||||||
|
# Copyright (c) 1999 Scriptics Corporation.
|
||||||
|
# Copyright (c) 2002-2005 ActiveState Corporation.
|
||||||
|
#
|
||||||
|
# See the file "license.terms" for information on usage and redistribution
|
||||||
|
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
|
#
|
||||||
|
# RCS: @(#) $Id: Makefile.in,v 1.26 2009/12/23 21:46:16 gregcouch Exp $
|
||||||
|
|
||||||
|
#========================================================================
|
||||||
|
# Add additional lines to handle any additional AC_SUBST cases that
|
||||||
|
# have been added in a customized configure script.
|
||||||
|
#========================================================================
|
||||||
|
|
||||||
|
#SAMPLE_NEW_VAR = @SAMPLE_NEW_VAR@
|
||||||
|
SHLIB_SUFFIX = @SHLIB_SUFFIX@
|
||||||
|
MATH_LIBS = @MATH_LIBS@
|
||||||
|
LIBGLU = @LIBGLU@
|
||||||
|
|
||||||
|
EXAMPLE_SRCS = double.c gears.c index.c overlay.c stereo.c texture.c pbuffer.c
|
||||||
|
EXAMPLE_OBJS = $(EXAMPLE_SRCS:.c=.$(OBJEXT))
|
||||||
|
EXAMPLE_SHLIBS = $(EXAMPLE_SRCS:.c=$(SHLIB_SUFFIX))
|
||||||
|
|
||||||
|
#========================================================================
|
||||||
|
# Nothing of the variables below this line should need to be changed.
|
||||||
|
# Please check the TARGETS section below to make sure the make targets
|
||||||
|
# are correct.
|
||||||
|
#========================================================================
|
||||||
|
|
||||||
|
#========================================================================
|
||||||
|
# The names of the source files is defined in the configure script.
|
||||||
|
# The object files are used for linking into the final library.
|
||||||
|
# This will be used when a dist target is added to the Makefile.
|
||||||
|
# It is not important to specify the directory, as long as it is the
|
||||||
|
# $(srcdir) or in the generic, win or unix subdirectory.
|
||||||
|
#========================================================================
|
||||||
|
|
||||||
|
PKG_SOURCES = @PKG_SOURCES@
|
||||||
|
PKG_OBJECTS = @PKG_OBJECTS@
|
||||||
|
|
||||||
|
PKG_STUB_SOURCES = @PKG_STUB_SOURCES@
|
||||||
|
PKG_STUB_OBJECTS = @PKG_STUB_OBJECTS@
|
||||||
|
|
||||||
|
#========================================================================
|
||||||
|
# PKG_TCL_SOURCES identifies Tcl runtime files that are associated with
|
||||||
|
# this package that need to be installed, if any.
|
||||||
|
#========================================================================
|
||||||
|
|
||||||
|
PKG_TCL_SOURCES = @PKG_TCL_SOURCES@
|
||||||
|
|
||||||
|
#========================================================================
|
||||||
|
# This is a list of public header files to be installed, if any.
|
||||||
|
#========================================================================
|
||||||
|
|
||||||
|
PKG_HEADERS = @PKG_HEADERS@ togl_ws.h
|
||||||
|
|
||||||
|
#========================================================================
|
||||||
|
# "PKG_LIB_FILE" refers to the library (dynamic or static as per
|
||||||
|
# configuration options) composed of the named objects.
|
||||||
|
#========================================================================
|
||||||
|
|
||||||
|
PKG_LIB_FILE = @PKG_LIB_FILE@
|
||||||
|
PKG_STUB_LIB_FILE = @PKG_STUB_LIB_FILE@
|
||||||
|
|
||||||
|
pkglib_BINARIES = $(PKG_LIB_FILE)
|
||||||
|
lib_BINARIES = $(PKG_STUB_LIB_FILE)
|
||||||
|
BINARIES = $(pkglib_BINARIES) $(lib_BINARIES)
|
||||||
|
|
||||||
|
SHELL = @SHELL@
|
||||||
|
|
||||||
|
srcdir = @srcdir@
|
||||||
|
prefix = @prefix@
|
||||||
|
exec_prefix = @exec_prefix@
|
||||||
|
|
||||||
|
bindir = @bindir@
|
||||||
|
libdir = @libdir@
|
||||||
|
includedir = @includedir@
|
||||||
|
datarootdir = @datarootdir@
|
||||||
|
datadir = @datadir@
|
||||||
|
mandir = @mandir@
|
||||||
|
|
||||||
|
DESTDIR =
|
||||||
|
|
||||||
|
PKG_DIR = $(PACKAGE_NAME)$(PACKAGE_VERSION)
|
||||||
|
pkgdatadir = $(datadir)/$(PKG_DIR)
|
||||||
|
pkglibdir = $(libdir)/$(PKG_DIR)
|
||||||
|
pkgincludedir = $(includedir)/$(PKG_DIR)
|
||||||
|
|
||||||
|
top_builddir = .
|
||||||
|
|
||||||
|
INSTALL = @INSTALL@
|
||||||
|
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||||
|
INSTALL_DATA = @INSTALL_DATA@
|
||||||
|
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||||
|
|
||||||
|
PACKAGE_NAME = @PACKAGE_NAME@
|
||||||
|
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||||
|
CC = @CC@
|
||||||
|
CFLAGS_DEFAULT = @CFLAGS_DEFAULT@
|
||||||
|
CFLAGS_WARNING = @CFLAGS_WARNING@
|
||||||
|
EXEEXT = @EXEEXT@
|
||||||
|
LDFLAGS_DEFAULT = @LDFLAGS_DEFAULT@
|
||||||
|
MAKE_LIB = @MAKE_LIB@
|
||||||
|
MAKE_SHARED_LIB = @MAKE_SHARED_LIB@
|
||||||
|
MAKE_STATIC_LIB = @MAKE_STATIC_LIB@
|
||||||
|
MAKE_STUB_LIB = @MAKE_STUB_LIB@
|
||||||
|
OBJEXT = @OBJEXT@
|
||||||
|
RANLIB = @RANLIB@
|
||||||
|
RANLIB_STUB = @RANLIB_STUB@
|
||||||
|
SHLIB_CFLAGS = @SHLIB_CFLAGS@
|
||||||
|
SHLIB_LD = @SHLIB_LD@
|
||||||
|
SHLIB_LD_LIBS = @SHLIB_LD_LIBS@
|
||||||
|
STLIB_LD = @STLIB_LD@
|
||||||
|
#TCL_DEFS = @TCL_DEFS@
|
||||||
|
TCL_BIN_DIR = @TCL_BIN_DIR@
|
||||||
|
TCL_SRC_DIR = @TCL_SRC_DIR@
|
||||||
|
#TK_BIN_DIR = @TK_BIN_DIR@
|
||||||
|
#TK_SRC_DIR = @TK_SRC_DIR@
|
||||||
|
|
||||||
|
# Not used, but retained for reference of what libs Tcl required
|
||||||
|
#TCL_LIBS = @TCL_LIBS@
|
||||||
|
|
||||||
|
#========================================================================
|
||||||
|
# TCLLIBPATH seeds the auto_path in Tcl's init.tcl so we can test our
|
||||||
|
# package without installing. The other environment variables allow us
|
||||||
|
# to test against an uninstalled Tcl. Add special env vars that you
|
||||||
|
# require for testing here (like TCLX_LIBRARY).
|
||||||
|
#========================================================================
|
||||||
|
|
||||||
|
#EXTRA_PATH = $(top_builddir):$(TCL_BIN_DIR)
|
||||||
|
EXTRA_PATH = $(top_builddir):$(TCL_BIN_DIR):$(TK_BIN_DIR)
|
||||||
|
TCLLIBPATH = $(top_builddir)
|
||||||
|
TCLSH_ENV = TCL_LIBRARY=`@CYGPATH@ $(TCL_SRC_DIR)/library` \
|
||||||
|
@LD_LIBRARY_PATH_VAR@="$(EXTRA_PATH):$(@LD_LIBRARY_PATH_VAR@)" \
|
||||||
|
PATH="$(EXTRA_PATH):$(PATH)" \
|
||||||
|
TCLLIBPATH="$(TCLLIBPATH)"
|
||||||
|
# TK_LIBRARY=`@CYGPATH@ $(TK_SRC_DIR)/library`
|
||||||
|
|
||||||
|
TCLSH_PROG = @TCLSH_PROG@
|
||||||
|
TCLSH = $(TCLSH_ENV) $(TCLSH_PROG)
|
||||||
|
|
||||||
|
WISH_PROG = @WISH_PROG@
|
||||||
|
WISH = $(TCLSH_ENV) $(WISH_PROG)
|
||||||
|
|
||||||
|
|
||||||
|
SHARED_BUILD = @SHARED_BUILD@
|
||||||
|
|
||||||
|
INCLUDES = -I. @PKG_INCLUDES@ @TCL_INCLUDES@ @TK_INCLUDES@ @TK_XINCLUDES@
|
||||||
|
|
||||||
|
PKG_CFLAGS = @PKG_CFLAGS@
|
||||||
|
|
||||||
|
# TCL_DEFS is not strictly need here, but if you remove it, then you
|
||||||
|
# must make sure that configure.in checks for the necessary components
|
||||||
|
# that your library may use. TCL_DEFS can actually be a problem if
|
||||||
|
# you do not compile with a similar machine setup as the Tcl core was
|
||||||
|
# compiled with.
|
||||||
|
#DEFS = $(TCL_DEFS) @DEFS@ $(PKG_CFLAGS)
|
||||||
|
DEFS = @DEFS@ -DAUTOSTEREOD=\"@AUTOSTEREOD@\" $(PKG_CFLAGS)
|
||||||
|
|
||||||
|
CONFIG_CLEAN_FILES = Makefile pkgIndex.tcl togl_ws.h
|
||||||
|
CLEANFILES = @CLEANFILES@ $(EXAMPLE_OBJS) $(EXAMPLE_SHLIBS)
|
||||||
|
|
||||||
|
CPPFLAGS = @CPPFLAGS@
|
||||||
|
LIBS = @PKG_LIBS@ @LIBS@
|
||||||
|
AR = @AR@
|
||||||
|
CFLAGS = @CFLAGS@
|
||||||
|
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||||
|
|
||||||
|
#========================================================================
|
||||||
|
# Start of user-definable TARGETS section
|
||||||
|
#========================================================================
|
||||||
|
|
||||||
|
#========================================================================
|
||||||
|
# TEA TARGETS. Please note that the "libraries:" target refers to platform
|
||||||
|
# independent files, and the "binaries:" target includes executable programs and
|
||||||
|
# platform-dependent libraries. Modify these targets so that they install
|
||||||
|
# the various pieces of your package. The make and install rules
|
||||||
|
# for the BINARIES that you specified above have already been done.
|
||||||
|
#========================================================================
|
||||||
|
|
||||||
|
all: binaries libraries doc
|
||||||
|
|
||||||
|
#========================================================================
|
||||||
|
# The binaries target builds executable programs, Windows .dll's, unix
|
||||||
|
# shared/static libraries, and any other platform-dependent files.
|
||||||
|
# The list of targets to build for "binaries:" is specified at the top
|
||||||
|
# of the Makefile, in the "BINARIES" variable.
|
||||||
|
#========================================================================
|
||||||
|
|
||||||
|
binaries: $(BINARIES)
|
||||||
|
|
||||||
|
libraries:
|
||||||
|
|
||||||
|
#========================================================================
|
||||||
|
# Example section. These are examples because we don't want to install them.
|
||||||
|
# And they're not tests because we currently have no automatic way to see
|
||||||
|
# if they work.
|
||||||
|
#========================================================================
|
||||||
|
|
||||||
|
examples: $(EXAMPLE_SHLIBS)
|
||||||
|
|
||||||
|
double$(SHLIB_SUFFIX): double.$(OBJEXT) $(PKG_STUB_LIB_FILE)
|
||||||
|
-match=`expr 'x$(PKG_OBJECTS)' : '.*togl.*'`; \
|
||||||
|
if [ $$match -eq 0 ]; then \
|
||||||
|
$(MAKE_SHARED_LIB) ; \
|
||||||
|
else \
|
||||||
|
$(MAKE) PKG_OBJECTS="double.$(OBJEXT) $(PKG_STUB_LIB_FILE)" $@ ; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
gears$(SHLIB_SUFFIX): gears.$(OBJEXT) $(PKG_STUB_LIB_FILE)
|
||||||
|
-match=`expr 'x$(PKG_OBJECTS)' : '.*togl.*'`; \
|
||||||
|
if [ $$match -eq 0 ]; then \
|
||||||
|
$(MAKE_SHARED_LIB) ; \
|
||||||
|
else \
|
||||||
|
$(MAKE) PKG_OBJECTS="gears.$(OBJEXT) $(PKG_STUB_LIB_FILE)" $@ ; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
index$(SHLIB_SUFFIX): index.$(OBJEXT) $(PKG_STUB_LIB_FILE)
|
||||||
|
-match=`expr 'x$(PKG_OBJECTS)' : '.*togl.*'`; \
|
||||||
|
if [ $$match -eq 0 ]; then \
|
||||||
|
$(MAKE_SHARED_LIB) ; \
|
||||||
|
else \
|
||||||
|
$(MAKE) PKG_OBJECTS="index.$(OBJEXT) $(PKG_STUB_LIB_FILE)" $@ ; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
overlay$(SHLIB_SUFFIX): overlay.$(OBJEXT) $(PKG_STUB_LIB_FILE)
|
||||||
|
-match=`expr 'x$(PKG_OBJECTS)' : '.*togl.*'`; \
|
||||||
|
if [ $$match -eq 0 ]; then \
|
||||||
|
$(MAKE_SHARED_LIB) ; \
|
||||||
|
else \
|
||||||
|
$(MAKE) PKG_OBJECTS="overlay.$(OBJEXT) $(PKG_STUB_LIB_FILE)" $@ ; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
stereo$(SHLIB_SUFFIX): stereo.$(OBJEXT) $(PKG_STUB_LIB_FILE)
|
||||||
|
-match=`expr 'x$(PKG_OBJECTS)' : '.*togl.*'`; \
|
||||||
|
if [ $$match -eq 0 ]; then \
|
||||||
|
$(MAKE_SHARED_LIB) ; \
|
||||||
|
else \
|
||||||
|
$(MAKE) PKG_OBJECTS="stereo.$(OBJEXT) $(PKG_STUB_LIB_FILE)" $@ ; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
texture$(SHLIB_SUFFIX): texture.$(OBJEXT) image.$(OBJEXT) $(PKG_STUB_LIB_FILE)
|
||||||
|
-match=`expr 'x$(PKG_OBJECTS)' : '.*togl.*'`; \
|
||||||
|
if [ $$match -eq 0 ]; then \
|
||||||
|
$(MAKE_SHARED_LIB) ; \
|
||||||
|
else \
|
||||||
|
$(MAKE) PKG_OBJECTS="texture.$(OBJEXT) image.$(OBJEXT) $(PKG_STUB_LIB_FILE) $(LIBGLU)" $@ ; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
pbuffer$(SHLIB_SUFFIX): pbuffer.$(OBJEXT) $(PKG_STUB_LIB_FILE)
|
||||||
|
-match=`expr 'x$(PKG_OBJECTS)' : '.*togl.*'`; \
|
||||||
|
if [ $$match -eq 0 ]; then \
|
||||||
|
$(MAKE_SHARED_LIB) ; \
|
||||||
|
else \
|
||||||
|
$(MAKE) PKG_OBJECTS="pbuffer.$(OBJEXT) $(PKG_STUB_LIB_FILE) $(LIBGLU)" $@ ; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
#========================================================================
|
||||||
|
# Stub section.
|
||||||
|
#========================================================================
|
||||||
|
|
||||||
|
toglDecls.h toglStubInit.c: togl.decls
|
||||||
|
$(TCLSH) `@CYGPATH@ $(TCL_SRC_DIR)/tools/genStubs.tcl` . togl.decls
|
||||||
|
|
||||||
|
#========================================================================
|
||||||
|
# Your doc target should differentiate from doc builds (by the developer)
|
||||||
|
# and doc installs (see install-doc), which just install the docs on the
|
||||||
|
# end user machine when building from source.
|
||||||
|
#========================================================================
|
||||||
|
|
||||||
|
doc:
|
||||||
|
# @echo "If you have documentation to create, place the commands to"
|
||||||
|
# @echo "build the docs in the 'doc:' target. For example:"
|
||||||
|
# @echo " xml2nroff sample.xml > sample.n"
|
||||||
|
# @echo " xml2html sample.xml > sample.html"
|
||||||
|
|
||||||
|
install: all install-binaries install-libraries install-doc
|
||||||
|
|
||||||
|
install-binaries: binaries install-lib-binaries install-bin-binaries
|
||||||
|
|
||||||
|
#========================================================================
|
||||||
|
# This rule installs platform-independent files, such as header files.
|
||||||
|
# The list=...; for p in $$list handles the empty list case x-platform.
|
||||||
|
#========================================================================
|
||||||
|
|
||||||
|
install-libraries: libraries
|
||||||
|
@mkdir -p $(DESTDIR)$(includedir)
|
||||||
|
@echo "Installing header files in $(DESTDIR)$(includedir)"
|
||||||
|
@list='$(PKG_HEADERS)'; for i in $$list; do \
|
||||||
|
echo "Installing $(srcdir)/$$i" ; \
|
||||||
|
$(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(includedir) ; \
|
||||||
|
done
|
||||||
|
|
||||||
|
#========================================================================
|
||||||
|
# Install documentation. Unix manpages should go in the $(mandir)
|
||||||
|
# directory.
|
||||||
|
#========================================================================
|
||||||
|
|
||||||
|
install-doc: doc
|
||||||
|
# @mkdir -p $(DESTDIR)$(mandir)/mann
|
||||||
|
# @echo "Installing documentation in $(DESTDIR)$(mandir)"
|
||||||
|
# @list='$(srcdir)/doc/*.n'; for i in $$list; do \
|
||||||
|
# echo "Installing $$i"; \
|
||||||
|
# rm -f $(DESTDIR)$(mandir)/mann/`basename $$i`; \
|
||||||
|
# $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/mann ; \
|
||||||
|
# done
|
||||||
|
|
||||||
|
test: binaries libraries
|
||||||
|
$(TCLSH) `@CYGPATH@ $(srcdir)/tests/all.tcl` $(TESTFLAGS)
|
||||||
|
|
||||||
|
shell: binaries libraries
|
||||||
|
@$(TCLSH) $(SCRIPT)
|
||||||
|
|
||||||
|
gdb:
|
||||||
|
$(TCLSH_ENV) gdb $(TCLSH_PROG) $(SCRIPT)
|
||||||
|
|
||||||
|
depend:
|
||||||
|
|
||||||
|
#========================================================================
|
||||||
|
# $(PKG_LIB_FILE) should be listed as part of the BINARIES variable
|
||||||
|
# mentioned above. That will ensure that this target is built when you
|
||||||
|
# run "make binaries".
|
||||||
|
#
|
||||||
|
# The $(PKG_OBJECTS) objects are created and linked into the final
|
||||||
|
# library. In most cases these object files will correspond to the
|
||||||
|
# source files above.
|
||||||
|
#========================================================================
|
||||||
|
|
||||||
|
$(PKG_LIB_FILE): $(PKG_OBJECTS)
|
||||||
|
-rm -f $(PKG_LIB_FILE)
|
||||||
|
${MAKE_LIB}
|
||||||
|
$(RANLIB) $(PKG_LIB_FILE)
|
||||||
|
|
||||||
|
$(PKG_STUB_LIB_FILE): $(PKG_STUB_OBJECTS)
|
||||||
|
-rm -f $(PKG_STUB_LIB_FILE)
|
||||||
|
${MAKE_STUB_LIB}
|
||||||
|
$(RANLIB_STUB) $(PKG_STUB_LIB_FILE)
|
||||||
|
|
||||||
|
#========================================================================
|
||||||
|
# We need to enumerate the list of .c to .o lines here.
|
||||||
|
#
|
||||||
|
# In the following lines, $(srcdir) refers to the toplevel directory
|
||||||
|
# containing your extension. If your sources are in a subdirectory,
|
||||||
|
# you will have to modify the paths to reflect this:
|
||||||
|
#
|
||||||
|
# sample.$(OBJEXT): $(srcdir)/generic/sample.c
|
||||||
|
# $(COMPILE) -c `@CYGPATH@ $(srcdir)/generic/sample.c` -o $@
|
||||||
|
#
|
||||||
|
# Setting the VPATH variable to a list of paths will cause the makefile
|
||||||
|
# to look into these paths when resolving .c to .obj dependencies.
|
||||||
|
# As necessary, add $(srcdir):$(srcdir)/compat:....
|
||||||
|
#========================================================================
|
||||||
|
|
||||||
|
VPATH = $(srcdir):Xmu
|
||||||
|
|
||||||
|
.c.@OBJEXT@:
|
||||||
|
$(COMPILE) -c `@CYGPATH@ $<` -o $@
|
||||||
|
|
||||||
|
#========================================================================
|
||||||
|
# Distribution creation
|
||||||
|
# You may need to tweak this target to make it work correctly.
|
||||||
|
#========================================================================
|
||||||
|
|
||||||
|
COMPRESS = tar zcvf $(PKG_DIR)-src.tar.gz $(PKG_DIR)
|
||||||
|
DIST_ROOT = /tmp/togl-dist
|
||||||
|
DIST_DIR = $(DIST_ROOT)/$(PKG_DIR)
|
||||||
|
BINPKG_DIR = $(PKG_DIR)-@TCL_VERSION@-$(subst Darwin,MacOSX,$(subst CYGWIN,Windows,$(shell uname -s | sed -e 's/[-_].*//')))
|
||||||
|
BINDIST_DIR = $(DIST_ROOT)/$(BINPKG_DIR)
|
||||||
|
|
||||||
|
dist-clean:
|
||||||
|
rm -rf $(DIST_DIR) $(DIST_ROOT)/$(PKG_DIR)*
|
||||||
|
|
||||||
|
dist: dist-clean
|
||||||
|
mkdir -p $(DIST_DIR)
|
||||||
|
cp -p $(srcdir)/README* $(srcdir)/LICENSE* $(srcdir)/togl.decls \
|
||||||
|
$(srcdir)/*.py $(srcdir)/*.tcl \
|
||||||
|
$(srcdir)/aclocal.m4 $(srcdir)/configure $(srcdir)/*.in \
|
||||||
|
ben.rgb tree2.rgba \
|
||||||
|
$(DIST_DIR)/
|
||||||
|
chmod 664 $(DIST_DIR)/*
|
||||||
|
chmod 775 $(DIST_DIR)/configure $(DIST_DIR)/configure.in
|
||||||
|
|
||||||
|
for i in $(srcdir)/*.[ch]; do \
|
||||||
|
if [ -f $$i ]; then \
|
||||||
|
cp -p $$i $(DIST_DIR)/ ; \
|
||||||
|
fi; \
|
||||||
|
done
|
||||||
|
cd $(DIST_DIR); rm -f $(CONFIG_CLEAN_FILES)
|
||||||
|
|
||||||
|
mkdir $(DIST_DIR)/tclconfig
|
||||||
|
cp $(srcdir)/tclconfig/install-sh $(srcdir)/tclconfig/tcl.m4 \
|
||||||
|
$(DIST_DIR)/tclconfig/
|
||||||
|
chmod 664 $(DIST_DIR)/tclconfig/tcl.m4
|
||||||
|
chmod +x $(DIST_DIR)/tclconfig/install-sh
|
||||||
|
|
||||||
|
list='examples doc tests Xmu GL'; \
|
||||||
|
for p in $$list; do \
|
||||||
|
if test -d $(srcdir)/$$p ; then \
|
||||||
|
mkdir $(DIST_DIR)/$$p; \
|
||||||
|
cp -p $(srcdir)/$$p/*.* $(DIST_DIR)/$$p/; \
|
||||||
|
fi; \
|
||||||
|
done
|
||||||
|
|
||||||
|
(cd $(DIST_ROOT); $(COMPRESS);)
|
||||||
|
|
||||||
|
bindist-clean:
|
||||||
|
rm -rf $(BINDIST_DIR) $(DIST_ROOT)/$(PKG_DIR)*
|
||||||
|
|
||||||
|
bindist: all bindist-clean
|
||||||
|
mkdir -p $(BINDIST_DIR)
|
||||||
|
$(MAKE) prefix=$(BINDIST_DIR) exec_prefix=$(BINDIST_DIR) install
|
||||||
|
$(INSTALL_DATA) README.bin $(BINDIST_DIR)/README.txt
|
||||||
|
mkdir -p $(BINDIST_DIR)/doc
|
||||||
|
@list='doc/*.html doc/*.js'; for i in $$list; do \
|
||||||
|
echo "Installing $$i"; \
|
||||||
|
rm -f $(BINDIST_DIR)/doc/`basename $$i`; \
|
||||||
|
$(INSTALL_DATA) $$i $(BINDIST_DIR)/doc ; \
|
||||||
|
done
|
||||||
|
if [ @TOGL_WINDOWINGSYSTEM@ == TOGL_WGL ]; then \
|
||||||
|
(cd $(DIST_ROOT); zip -rDX9 $(BINPKG_DIR).zip $(BINPKG_DIR)); \
|
||||||
|
else \
|
||||||
|
(cd $(DIST_ROOT); tar zcvf $(BINPKG_DIR).tar.gz $(BINPKG_DIR)); \
|
||||||
|
fi
|
||||||
|
|
||||||
|
#========================================================================
|
||||||
|
# End of user-definable section
|
||||||
|
#========================================================================
|
||||||
|
|
||||||
|
#========================================================================
|
||||||
|
# Don't modify the file to clean here. Instead, set the "CLEANFILES"
|
||||||
|
# variable in configure.in
|
||||||
|
#========================================================================
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-test -z "$(BINARIES)" || rm -f $(BINARIES)
|
||||||
|
-rm -f *.$(OBJEXT) core *.core
|
||||||
|
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
-rm -f *.tab.c
|
||||||
|
-rm -f $(CONFIG_CLEAN_FILES)
|
||||||
|
-rm -f config.cache config.log config.status
|
||||||
|
|
||||||
|
#========================================================================
|
||||||
|
# Install binary object libraries. On Windows this includes both .dll and
|
||||||
|
# .lib files. Because the .lib files are not explicitly listed anywhere,
|
||||||
|
# we need to deduce their existence from the .dll file of the same name.
|
||||||
|
# Library files go into the lib directory.
|
||||||
|
# In addition, this will generate the pkgIndex.tcl
|
||||||
|
# file in the install location (assuming it can find a usable tclsh shell)
|
||||||
|
#
|
||||||
|
# You should not have to modify this target.
|
||||||
|
#========================================================================
|
||||||
|
|
||||||
|
install-lib-binaries: binaries
|
||||||
|
@mkdir -p $(DESTDIR)$(libdir)
|
||||||
|
@list='$(lib_BINARIES)'; for p in $$list; do \
|
||||||
|
if test -f $$p; then \
|
||||||
|
echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(libdir)/$$p"; \
|
||||||
|
$(INSTALL_PROGRAM) $$p $(DESTDIR)$(libdir)/$$p; \
|
||||||
|
stub=`echo $$p|sed -e "s/.*\(stub\).*/\1/"`; \
|
||||||
|
if test "x$$stub" = "xstub"; then \
|
||||||
|
echo " $(RANLIB_STUB) $(DESTDIR)$(libdir)/$$p"; \
|
||||||
|
$(RANLIB_STUB) $(DESTDIR)$(libdir)/$$p; \
|
||||||
|
else \
|
||||||
|
echo " $(RANLIB) $(DESTDIR)$(libdir)/$$p"; \
|
||||||
|
$(RANLIB) $(DESTDIR)$(libdir)/$$p; \
|
||||||
|
fi; \
|
||||||
|
ext=`echo $$p|sed -e "s/.*\.//"`; \
|
||||||
|
if test "x$$ext" = "xdll"; then \
|
||||||
|
lib=`basename $$p|sed -e 's/.[^.]*$$//'`.lib; \
|
||||||
|
if test -f $$lib; then \
|
||||||
|
echo " $(INSTALL_DATA) $$lib $(DESTDIR)$(libdir)/$$lib"; \
|
||||||
|
$(INSTALL_DATA) $$lib $(DESTDIR)$(libdir)/$$lib; \
|
||||||
|
fi; \
|
||||||
|
fi; \
|
||||||
|
fi; \
|
||||||
|
done
|
||||||
|
@mkdir -p $(DESTDIR)$(pkglibdir)
|
||||||
|
@list='$(pkglib_BINARIES)'; for p in $$list; do \
|
||||||
|
if test -f $$p; then \
|
||||||
|
echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(pkglibdir)/$$p"; \
|
||||||
|
$(INSTALL_PROGRAM) $$p $(DESTDIR)$(pkglibdir)/$$p; \
|
||||||
|
stub=`echo $$p|sed -e "s/.*\(stub\).*/\1/"`; \
|
||||||
|
if test "x$$stub" = "xstub"; then \
|
||||||
|
echo " $(RANLIB_STUB) $(DESTDIR)$(pkglibdir)/$$p"; \
|
||||||
|
$(RANLIB_STUB) $(DESTDIR)$(pkglibdir)/$$p; \
|
||||||
|
else \
|
||||||
|
echo " $(RANLIB) $(DESTDIR)$(pkglibdir)/$$p"; \
|
||||||
|
$(RANLIB) $(DESTDIR)$(pkglibdir)/$$p; \
|
||||||
|
fi; \
|
||||||
|
ext=`echo $$p|sed -e "s/.*\.//"`; \
|
||||||
|
if test "x$$ext" = "xdll"; then \
|
||||||
|
lib=`basename $$p|sed -e 's/.[^.]*$$//'`.lib; \
|
||||||
|
if test -f $$lib; then \
|
||||||
|
echo " $(INSTALL_DATA) $$lib $(DESTDIR)$(pkglibdir)/$$lib"; \
|
||||||
|
$(INSTALL_DATA) $$lib $(DESTDIR)$(pkglibdir)/$$lib; \
|
||||||
|
fi; \
|
||||||
|
fi; \
|
||||||
|
fi; \
|
||||||
|
done
|
||||||
|
@list='$(PKG_TCL_SOURCES)'; for p in $$list; do \
|
||||||
|
if test -f $(srcdir)/$$p; then \
|
||||||
|
destp=`basename $$p`; \
|
||||||
|
echo " Install $$destp $(DESTDIR)$(pkglibdir)/$$destp"; \
|
||||||
|
$(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(pkglibdir)/$$destp; \
|
||||||
|
fi; \
|
||||||
|
done
|
||||||
|
@if test "x$(SHARED_BUILD)" = "x1"; then \
|
||||||
|
echo " Install pkgIndex.tcl $(DESTDIR)$(pkglibdir)"; \
|
||||||
|
$(INSTALL_DATA) pkgIndex.tcl $(DESTDIR)$(pkglibdir); \
|
||||||
|
echo " Install LICENSE $(DESTDIR)$(pkglibdir)"; \
|
||||||
|
$(INSTALL_DATA) LICENSE $(DESTDIR)$(pkglibdir); \
|
||||||
|
else \
|
||||||
|
echo " Install LICENSE.togl $(DESTDIR)$(libdir)"; \
|
||||||
|
$(INSTALL_DATA) LICENSE $(DESTDIR)$(libdir)/LICENSE.togl; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
#========================================================================
|
||||||
|
# Install binary executables (e.g. .exe files and dependent .dll files)
|
||||||
|
# This is for files that must go in the bin directory (located next to
|
||||||
|
# wish and tclsh), like dependent .dll files on Windows.
|
||||||
|
#
|
||||||
|
# You should not have to modify this target, except to define bin_BINARIES
|
||||||
|
# above if necessary.
|
||||||
|
#========================================================================
|
||||||
|
|
||||||
|
install-bin-binaries: binaries
|
||||||
|
@mkdir -p $(DESTDIR)$(bindir)
|
||||||
|
@list='$(bin_BINARIES)'; for p in $$list; do \
|
||||||
|
if test -f $$p; then \
|
||||||
|
echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$p"; \
|
||||||
|
$(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$p; \
|
||||||
|
fi; \
|
||||||
|
done
|
||||||
|
|
||||||
|
.SUFFIXES: .c .$(OBJEXT)
|
||||||
|
|
||||||
|
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||||
|
cd $(top_builddir) \
|
||||||
|
&& CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||||
|
|
||||||
|
uninstall-binaries:
|
||||||
|
list='$(pkglib_BINARIES)'; for p in $$list; do \
|
||||||
|
rm -f $(DESTDIR)$(pkglibdir)/$$p; \
|
||||||
|
done
|
||||||
|
list='$(lib_BINARIES)'; for p in $$list; do \
|
||||||
|
rm -f $(DESTDIR)$(libdir)/$$p; \
|
||||||
|
done
|
||||||
|
list='$(PKG_TCL_SOURCES)'; for p in $$list; do \
|
||||||
|
p=`basename $$p`; \
|
||||||
|
rm -f $(DESTDIR)$(pkglibdir)/$$p; \
|
||||||
|
done
|
||||||
|
list='$(bin_BINARIES)'; for p in $$list; do \
|
||||||
|
rm -f $(DESTDIR)$(bindir)/$$p; \
|
||||||
|
done
|
||||||
|
|
||||||
|
.PHONY: all binaries clean depend distclean doc install libraries test
|
||||||
|
|
||||||
|
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||||
|
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||||
|
.NOEXPORT:
|
||||||
|
|
||||||
|
# Additional dependencies
|
||||||
|
togl.$(OBJEXT): toglFont.c toglAGL.c toglGLX.c toglWGL.c
|
73
ng/Togl2.1/README.bin
Normal file
73
ng/Togl2.1/README.bin
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
README.txt: Togl
|
||||||
|
|
||||||
|
This is a Togl 2.X binary distribution for both users and developers.
|
||||||
|
It is specific to a particular operating system (e.g., Windows, Mac
|
||||||
|
OS X, Linux, etc.). Since the C ABI should be same for all compilers
|
||||||
|
on the same system, using Togl via the Tcl interface should work
|
||||||
|
regardless of which compiler Tcl was compiled with.
|
||||||
|
|
||||||
|
The files are named:
|
||||||
|
|
||||||
|
ToglTOGL_VERSION-TCL_VERSION-OS.SUFFIX
|
||||||
|
|
||||||
|
For example, TOGL_VERSION=2.0, TCL_VERSION=8.4, OS=Linux,
|
||||||
|
and SUFFIX=.tar.gz gives:
|
||||||
|
|
||||||
|
Togl2.0-8.4-Linux.tar.gz
|
||||||
|
|
||||||
|
Togl is also available at:
|
||||||
|
http://sourceforge.net/projects/togl/
|
||||||
|
|
||||||
|
You can get any release of Togl from the file distributions
|
||||||
|
link at the above URL.
|
||||||
|
|
||||||
|
A copy of the online documentation is in the doc directory.
|
||||||
|
|
||||||
|
For users:
|
||||||
|
|
||||||
|
Only the lib/Togl2.X directory (and its contents) need to be installed
|
||||||
|
in your Tcl library. Execute the following Tcl script to find the
|
||||||
|
directories Tcl looks for packages in:
|
||||||
|
|
||||||
|
puts $tcl_libPath
|
||||||
|
|
||||||
|
and then copy the lib/Togl2.X directory into one of those directories.
|
||||||
|
|
||||||
|
For developers:
|
||||||
|
|
||||||
|
The lib/Togl2.X directory (and its contents) is all that needs to be
|
||||||
|
redistributed in your application distribution.
|
||||||
|
|
||||||
|
If you wish to link with Togl, then you will need the include files
|
||||||
|
and a link library for your compiler. The compilers used are (OS-
|
||||||
|
WINDOWING_SYSTEM):
|
||||||
|
|
||||||
|
MacOSX: gcc 4.0.1, Mac OS X 10.4, ppc/i386
|
||||||
|
Linux: gcc 3.3.6, Red Hat 7.1, i386
|
||||||
|
Linux64: gcc 4.2.3 -Wl,--hash-style=both, Red Hat Server 5.1, x86_64
|
||||||
|
Windows: Microsoft Visual Studio .NET 2003, Windows XP SP2, i386
|
||||||
|
|
||||||
|
File hierarchy:
|
||||||
|
|
||||||
|
README.txt this file
|
||||||
|
bin/ unused (empty)
|
||||||
|
lib/
|
||||||
|
Togl2.X/ Tcl package (place on Tcl's autopath)
|
||||||
|
LICENSE redistribution license
|
||||||
|
pkgIndex.tcl Tcl package index
|
||||||
|
Togl2X.dll Windows Tcl package binary
|
||||||
|
Toglstub2X.a Windows gcc/mingw link library
|
||||||
|
Toglstub2X.lib Windows Visual Studio link library
|
||||||
|
libToglstub2X.a UNIX (Linux, IRIX, etc.) link library
|
||||||
|
include/
|
||||||
|
togl.h Main header file, includes others
|
||||||
|
toglDecls.h API function declarations
|
||||||
|
togl_ws.h Which windowing system togl was compiled with
|
||||||
|
doc/ Documentation
|
||||||
|
*.html Start with index.html
|
||||||
|
|
||||||
|
The contents of the include and lib directories can be placed verbatim
|
||||||
|
in the Tcl installataion hierachy.
|
||||||
|
|
||||||
|
Documentation is in the doc directory. Start with doc/index.html in
|
||||||
|
your web browser.
|
21
ng/Togl2.1/README.stubs
Normal file
21
ng/Togl2.1/README.stubs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
This version of Togl is entirely free from
|
||||||
|
dependencies on Tcl/Tk's internal functions. It uses the public stubs
|
||||||
|
interface, witch means that the same binary works with any stubs-aware
|
||||||
|
wish (i.e. version >= 8.1)
|
||||||
|
|
||||||
|
It has been tested on Windows NT/2000 and Linux for several Tcl/Tk versions up
|
||||||
|
to 8.4a3. I haven't been able to test the Mac port, it propably needs mending
|
||||||
|
but I can't see why it shouldn't work in principle.
|
||||||
|
|
||||||
|
Implementation wise, what differs from Togl 1.5 is that Togl_MakeWindowExist()
|
||||||
|
is replaced by Togl_CreateWindow(), a function that gets registered in Tk as a callback for window creation. In Tk/Tk 8.4a3, there is a new public API call
|
||||||
|
Tk_SetClassProcs() to register this callback, but for earlier versions of Tk
|
||||||
|
one needs to do this using some pointer magic.
|
||||||
|
There is a run-time check to determine which method to use, hence the
|
||||||
|
same binary runs on all versions of Wish from 8.1 and up. For this to
|
||||||
|
work you need to compile against the headers from Tcl/Tk 8.4a3 or later, or
|
||||||
|
the binary will only work for Tcl/Tk 8.1-8.4a2.
|
||||||
|
The tk8.4a3 public headers (tk8.4a3.h + tkDecls.h) are included for
|
||||||
|
conveniance, and they are used if the flag -DUSE_LOCAL_TK_H is specified.
|
||||||
|
|
||||||
|
Jonas Beskow, December 2001
|
129
ng/Togl2.1/Togl.py
Normal file
129
ng/Togl2.1/Togl.py
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
|
||||||
|
"""
|
||||||
|
Tkinter support for the Togl 2.X Tk OpenGL widget.
|
||||||
|
|
||||||
|
Copyright (C) 2006-2007 Greg Couch
|
||||||
|
See the LICENSE file for copyright details.
|
||||||
|
"""
|
||||||
|
__all__ = ['Togl', 'NORMAL', 'OVERLAY']
|
||||||
|
|
||||||
|
import Tkinter
|
||||||
|
import weakref, atexit
|
||||||
|
|
||||||
|
# Overlay constants
|
||||||
|
NORMAL = 1
|
||||||
|
OVERLAY = 2
|
||||||
|
|
||||||
|
class Togl(Tkinter.Widget):
|
||||||
|
"""Tk OpenGL Widget"""
|
||||||
|
_instances = weakref.WeakKeyDictionary()
|
||||||
|
|
||||||
|
def __init__(self, master=None, cnf={}, **kw):
|
||||||
|
"""Return new Togl widget"""
|
||||||
|
if master is None:
|
||||||
|
master = Tkinter._default_root
|
||||||
|
master.tk.call('package', 'require', 'Togl', '2.0')
|
||||||
|
try:
|
||||||
|
Tkinter.Widget.__init__(self, master, "togl", cnf, kw)
|
||||||
|
except:
|
||||||
|
Tkinter.Widget.destroy(self)
|
||||||
|
raise
|
||||||
|
Togl._instances[self] = True
|
||||||
|
|
||||||
|
def _cbsubst(self, *args):
|
||||||
|
"""callback command argument substitution"""
|
||||||
|
if len(args) != 1:
|
||||||
|
return args
|
||||||
|
return (self._nametowidget(args[0]),)
|
||||||
|
|
||||||
|
def _options(self, cnf, kw = None):
|
||||||
|
"""Internal function."""
|
||||||
|
if kw:
|
||||||
|
cnf = Tkinter._cnfmerge((cnf, kw))
|
||||||
|
else:
|
||||||
|
cnf = Tkinter._cnfmerge(cnf)
|
||||||
|
res = ()
|
||||||
|
for k, v in cnf.items():
|
||||||
|
if v is not None:
|
||||||
|
if k[-1] == '_': k = k[:-1]
|
||||||
|
if callable(v):
|
||||||
|
if k.endswith('command'):
|
||||||
|
v = self._register(v, self._cbsubst)
|
||||||
|
else:
|
||||||
|
v = self._register(v)
|
||||||
|
res = res + ('-'+k, v)
|
||||||
|
return res
|
||||||
|
|
||||||
|
# cget, configure are inherited
|
||||||
|
|
||||||
|
def extensions(self):
|
||||||
|
"""Return list of supported OpenGL extensions"""
|
||||||
|
return self.tk.call(self._w, 'extensions')
|
||||||
|
|
||||||
|
def postredisplay(self):
|
||||||
|
"""Cause the displaycommand callback to be called
|
||||||
|
the next time the event loop is idle."""
|
||||||
|
self.tk.call(self._w, 'postredisplay')
|
||||||
|
|
||||||
|
def render(self):
|
||||||
|
"""Call the displaycommand callback immediately."""
|
||||||
|
self.tk.call(self._w, 'render')
|
||||||
|
|
||||||
|
def swapbuffers(self):
|
||||||
|
"""If single-buffred, just flush OpenGL command buffer. If
|
||||||
|
double-buffered, swap front and back buffers. (So this is
|
||||||
|
appropriate to call after every frame is drawn.)"""
|
||||||
|
self.tk.call(self._w, 'swapbuffers')
|
||||||
|
|
||||||
|
def makecurrent(self):
|
||||||
|
"""Make widget the current OpenGL context"""
|
||||||
|
self.tk.call(self._w, 'makecurrent')
|
||||||
|
|
||||||
|
def takephoto(self, imageName):
|
||||||
|
"""Copy current contents of widget into the given photo image
|
||||||
|
"""
|
||||||
|
self.tk.call(self._w, 'takephoto', imageName)
|
||||||
|
|
||||||
|
def loadbitmapfont(self, name):
|
||||||
|
return self.tk.call(self._w, 'loadbitmapfont', name)
|
||||||
|
|
||||||
|
def unloadbitmapfont(self, fontbase):
|
||||||
|
self.tk.call(self._w, 'unloadbitmapfont', fontbase)
|
||||||
|
|
||||||
|
def uselayer(self, layer):
|
||||||
|
self.tk.call(self._w, 'uselayer', layer)
|
||||||
|
|
||||||
|
def showoverlay(self):
|
||||||
|
self.tk.call(self._w, 'showoverlay')
|
||||||
|
|
||||||
|
def hideoverlay(self):
|
||||||
|
self.tk.call(self._w, 'hideoverlay')
|
||||||
|
|
||||||
|
def postredisplayoverlay(self):
|
||||||
|
self.tk.call(self._w, 'postredisplayoverlay')
|
||||||
|
|
||||||
|
def renderoverlay(self):
|
||||||
|
self.tk.call(self._w, 'renderoverlay')
|
||||||
|
|
||||||
|
def existsoverlay(self):
|
||||||
|
return self.tk.call(self._w, 'existsoverlay')
|
||||||
|
|
||||||
|
def ismappedoverlay(self):
|
||||||
|
return self.tk.call(self._w, 'ismappedoverlay')
|
||||||
|
|
||||||
|
def getoverlaytransparentvalue(self):
|
||||||
|
return self.tk.call(self._w, 'getoverlaytransparentvalue')
|
||||||
|
|
||||||
|
def destroy(self):
|
||||||
|
del Togl._instances[self]
|
||||||
|
Tkinter.Widget.destroy(self)
|
||||||
|
|
||||||
|
def _cleanup():
|
||||||
|
# destroy OpenGL contexts early, so destroycommand's don't
|
||||||
|
# try to make any OpenGL calls during exit.
|
||||||
|
for t in Togl._instances.keys():
|
||||||
|
try:
|
||||||
|
t.destroy()
|
||||||
|
except Tkinter.TclError:
|
||||||
|
pass
|
||||||
|
atexit.register(_cleanup)
|
335
ng/Togl2.1/Xmu/CmapAlloc.c
Normal file
335
ng/Togl2.1/Xmu/CmapAlloc.c
Normal file
@ -0,0 +1,335 @@
|
|||||||
|
/* $XConsortium: CmapAlloc.c,v 1.9 94/04/17 20:15:52 rws Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 1989, 1994 X Consortium
|
||||||
|
|
||||||
|
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 THE
|
||||||
|
X CONSORTIUM 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 X Consortium 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 X Consortium.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Author: Donna Converse, MIT X Consortium
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xatom.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define lowbit(x) ((x) & (~(x) + 1))
|
||||||
|
|
||||||
|
static int default_allocation();
|
||||||
|
static void best_allocation();
|
||||||
|
static void gray_allocation();
|
||||||
|
static int icbrt();
|
||||||
|
static int icbrt_with_bits();
|
||||||
|
static int icbrt_with_guess();
|
||||||
|
|
||||||
|
/* To determine the best allocation of reds, greens, and blues in a
|
||||||
|
* standard colormap, use XmuGetColormapAllocation.
|
||||||
|
* vinfo specifies visual information for a chosen visual
|
||||||
|
* property specifies one of the standard colormap property names
|
||||||
|
* red_max returns maximum red value
|
||||||
|
* green_max returns maximum green value
|
||||||
|
* blue_max returns maximum blue value
|
||||||
|
*
|
||||||
|
* XmuGetColormapAllocation returns 0 on failure, non-zero on success.
|
||||||
|
* It is assumed that the visual is appropriate for the colormap property.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Status XmuGetColormapAllocation(vinfo, property, red_max, green_max, blue_max)
|
||||||
|
XVisualInfo *vinfo;
|
||||||
|
Atom property;
|
||||||
|
unsigned long *red_max, *green_max, *blue_max;
|
||||||
|
{
|
||||||
|
Status status = 1;
|
||||||
|
|
||||||
|
if (vinfo->colormap_size <= 2)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
switch (property)
|
||||||
|
{
|
||||||
|
case XA_RGB_DEFAULT_MAP:
|
||||||
|
status = default_allocation(vinfo, red_max, green_max, blue_max);
|
||||||
|
break;
|
||||||
|
case XA_RGB_BEST_MAP:
|
||||||
|
best_allocation(vinfo, red_max, green_max, blue_max);
|
||||||
|
break;
|
||||||
|
case XA_RGB_GRAY_MAP:
|
||||||
|
gray_allocation(vinfo->colormap_size, red_max, green_max, blue_max);
|
||||||
|
break;
|
||||||
|
case XA_RGB_RED_MAP:
|
||||||
|
*red_max = vinfo->colormap_size - 1;
|
||||||
|
*green_max = *blue_max = 0;
|
||||||
|
break;
|
||||||
|
case XA_RGB_GREEN_MAP:
|
||||||
|
*green_max = vinfo->colormap_size - 1;
|
||||||
|
*red_max = *blue_max = 0;
|
||||||
|
break;
|
||||||
|
case XA_RGB_BLUE_MAP:
|
||||||
|
*blue_max = vinfo->colormap_size - 1;
|
||||||
|
*red_max = *green_max = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
status = 0;
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
/* Determine the appropriate color allocations of a gray scale.
|
||||||
|
*
|
||||||
|
* Keith Packard, MIT X Consortium
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void gray_allocation(n, red_max, green_max, blue_max)
|
||||||
|
int n; /* the number of cells of the gray scale */
|
||||||
|
unsigned long *red_max, *green_max, *blue_max;
|
||||||
|
{
|
||||||
|
*red_max = (n * 30) / 100;
|
||||||
|
*green_max = (n * 59) / 100;
|
||||||
|
*blue_max = (n * 11) / 100;
|
||||||
|
*green_max += ((n - 1) - (*red_max + *green_max + *blue_max));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
/* Determine an appropriate color allocation for the RGB_DEFAULT_MAP.
|
||||||
|
* If a map has less than a minimum number of definable entries, we do not
|
||||||
|
* produce an allocation for an RGB_DEFAULT_MAP.
|
||||||
|
*
|
||||||
|
* For 16 planes, the default colormap will have 27 each RGB; for 12 planes,
|
||||||
|
* 12 each. For 8 planes, let n = the number of colormap entries, which may
|
||||||
|
* be 256 or 254. Then, maximum red value = floor(cube_root(n - 125)) - 1.
|
||||||
|
* Maximum green and maximum blue values are identical to maximum red.
|
||||||
|
* This leaves at least 125 cells which clients can allocate.
|
||||||
|
*
|
||||||
|
* Return 0 if an allocation has been determined, non-zero otherwise.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int default_allocation(vinfo, red, green, blue)
|
||||||
|
XVisualInfo *vinfo;
|
||||||
|
unsigned long *red, *green, *blue;
|
||||||
|
{
|
||||||
|
int ngrays; /* number of gray cells */
|
||||||
|
|
||||||
|
switch (vinfo->class) {
|
||||||
|
case PseudoColor:
|
||||||
|
|
||||||
|
if (vinfo->colormap_size > 65000)
|
||||||
|
/* intended for displays with 16 planes */
|
||||||
|
*red = *green = *blue = (unsigned long) 27;
|
||||||
|
else if (vinfo->colormap_size > 4000)
|
||||||
|
/* intended for displays with 12 planes */
|
||||||
|
*red = *green = *blue = (unsigned long) 12;
|
||||||
|
else if (vinfo->colormap_size < 250)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
/* intended for displays with 8 planes */
|
||||||
|
*red = *green = *blue = (unsigned long)
|
||||||
|
(icbrt(vinfo->colormap_size - 125) - 1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DirectColor:
|
||||||
|
|
||||||
|
if (vinfo->colormap_size < 10)
|
||||||
|
return 0;
|
||||||
|
*red = *green = *blue = vinfo->colormap_size / 2 - 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TrueColor:
|
||||||
|
|
||||||
|
*red = vinfo->red_mask / lowbit(vinfo->red_mask);
|
||||||
|
*green = vinfo->green_mask / lowbit(vinfo->green_mask);
|
||||||
|
*blue = vinfo->blue_mask / lowbit(vinfo->blue_mask);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GrayScale:
|
||||||
|
|
||||||
|
if (vinfo->colormap_size > 65000)
|
||||||
|
ngrays = 4096;
|
||||||
|
else if (vinfo->colormap_size > 4000)
|
||||||
|
ngrays = 512;
|
||||||
|
else if (vinfo->colormap_size < 250)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
ngrays = 12;
|
||||||
|
gray_allocation(ngrays, red, green, blue);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
/* Determine an appropriate color allocation for the RGB_BEST_MAP.
|
||||||
|
*
|
||||||
|
* For a DirectColor or TrueColor visual, the allocation is determined
|
||||||
|
* by the red_mask, green_mask, and blue_mask members of the visual info.
|
||||||
|
*
|
||||||
|
* Otherwise, if the colormap size is an integral power of 2, determine
|
||||||
|
* the allocation according to the number of bits given to each color,
|
||||||
|
* with green getting more than red, and red more than blue, if there
|
||||||
|
* are to be inequities in the distribution. If the colormap size is
|
||||||
|
* not an integral power of 2, let n = the number of colormap entries.
|
||||||
|
* Then maximum red value = floor(cube_root(n)) - 1;
|
||||||
|
* maximum blue value = floor(cube_root(n)) - 1;
|
||||||
|
* maximum green value = n / ((# red values) * (# blue values)) - 1;
|
||||||
|
* Which, on a GPX, allows for 252 entries in the best map, out of 254
|
||||||
|
* defineable colormap entries.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void best_allocation(vinfo, red, green, blue)
|
||||||
|
XVisualInfo *vinfo;
|
||||||
|
unsigned long *red, *green, *blue;
|
||||||
|
{
|
||||||
|
|
||||||
|
if (vinfo->class == DirectColor || vinfo->class == TrueColor)
|
||||||
|
{
|
||||||
|
*red = vinfo->red_mask;
|
||||||
|
while ((*red & 01) == 0)
|
||||||
|
*red >>= 1;
|
||||||
|
*green = vinfo->green_mask;
|
||||||
|
while ((*green & 01) == 0)
|
||||||
|
*green >>=1;
|
||||||
|
*blue = vinfo->blue_mask;
|
||||||
|
while ((*blue & 01) == 0)
|
||||||
|
*blue >>= 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
register int bits, n;
|
||||||
|
|
||||||
|
/* Determine n such that n is the least integral power of 2 which is
|
||||||
|
* greater than or equal to the number of entries in the colormap.
|
||||||
|
*/
|
||||||
|
n = 1;
|
||||||
|
bits = 0;
|
||||||
|
while (vinfo->colormap_size > n)
|
||||||
|
{
|
||||||
|
n = n << 1;
|
||||||
|
bits++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the number of entries in the colormap is a power of 2, determine
|
||||||
|
* the allocation by "dealing" the bits, first to green, then red, then
|
||||||
|
* blue. If not, find the maximum integral red, green, and blue values
|
||||||
|
* which, when multiplied together, do not exceed the number of
|
||||||
|
|
||||||
|
* colormap entries.
|
||||||
|
*/
|
||||||
|
if (n == vinfo->colormap_size)
|
||||||
|
{
|
||||||
|
register int r, g, b;
|
||||||
|
b = bits / 3;
|
||||||
|
g = b + ((bits % 3) ? 1 : 0);
|
||||||
|
r = b + (((bits % 3) == 2) ? 1 : 0);
|
||||||
|
*red = 1 << r;
|
||||||
|
*green = 1 << g;
|
||||||
|
*blue = 1 << b;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*red = icbrt_with_bits(vinfo->colormap_size, bits);
|
||||||
|
*blue = *red;
|
||||||
|
*green = (vinfo->colormap_size / ((*red) * (*blue)));
|
||||||
|
}
|
||||||
|
(*red)--;
|
||||||
|
(*green)--;
|
||||||
|
(*blue)--;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* integer cube roots by Newton's method
|
||||||
|
*
|
||||||
|
* Stephen Gildea, MIT X Consortium, July 1991
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int icbrt(a) /* integer cube root */
|
||||||
|
int a;
|
||||||
|
{
|
||||||
|
register int bits = 0;
|
||||||
|
register unsigned n = a;
|
||||||
|
|
||||||
|
while (n)
|
||||||
|
{
|
||||||
|
bits++;
|
||||||
|
n >>= 1;
|
||||||
|
}
|
||||||
|
return icbrt_with_bits(a, bits);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int icbrt_with_bits(a, bits)
|
||||||
|
int a;
|
||||||
|
int bits; /* log 2 of a */
|
||||||
|
{
|
||||||
|
return icbrt_with_guess(a, a>>2*bits/3);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _X_ROOT_STATS
|
||||||
|
int icbrt_loopcount;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Newton's Method: x_n+1 = x_n - ( f(x_n) / f'(x_n) ) */
|
||||||
|
|
||||||
|
/* for cube roots, x^3 - a = 0, x_new = x - 1/3 (x - a/x^2) */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Quick and dirty cube roots. Nothing fancy here, just Newton's method.
|
||||||
|
* Only works for positive integers (since that's all we need).
|
||||||
|
* We actually return floor(cbrt(a)) because that's what we need here, too.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int icbrt_with_guess(a, guess)
|
||||||
|
int a, guess;
|
||||||
|
{
|
||||||
|
register int delta;
|
||||||
|
|
||||||
|
#ifdef _X_ROOT_STATS
|
||||||
|
icbrt_loopcount = 0;
|
||||||
|
#endif
|
||||||
|
if (a <= 0)
|
||||||
|
return 0;
|
||||||
|
if (guess < 1)
|
||||||
|
guess = 1;
|
||||||
|
|
||||||
|
do {
|
||||||
|
#ifdef _X_ROOT_STATS
|
||||||
|
icbrt_loopcount++;
|
||||||
|
#endif
|
||||||
|
delta = (guess - a/(guess*guess))/3;
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("pass %d: guess=%d, delta=%d\n", icbrt_loopcount, guess, delta);
|
||||||
|
#endif
|
||||||
|
guess -= delta;
|
||||||
|
} while (delta != 0);
|
||||||
|
|
||||||
|
if (guess*guess*guess > a)
|
||||||
|
guess--;
|
||||||
|
|
||||||
|
return guess;
|
||||||
|
}
|
523
ng/Togl2.1/Xmu/CrCmap.c
Normal file
523
ng/Togl2.1/Xmu/CrCmap.c
Normal file
@ -0,0 +1,523 @@
|
|||||||
|
/* $XConsortium: CrCmap.c,v 1.6 94/04/17 20:15:53 rws Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 1989 X Consortium
|
||||||
|
|
||||||
|
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 THE
|
||||||
|
X CONSORTIUM 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 X Consortium 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 X Consortium.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Author: Donna Converse, MIT X Consortium
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CreateCmap.c - given a standard colormap description, make the map.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
static int ROmap(); /* allocate entire map Read Only */
|
||||||
|
static Status ROorRWcell(); /* allocate a cell, prefer Read Only */
|
||||||
|
static Status RWcell(); /* allocate a cell Read Write */
|
||||||
|
static int compare(); /* for quicksort */
|
||||||
|
static Status contiguous(); /* find contiguous sequence of cells */
|
||||||
|
static void free_cells(); /* frees resources before quitting */
|
||||||
|
static Status readonly_map(); /* create a map in a RO visual type */
|
||||||
|
static Status readwrite_map(); /* create a map in a RW visual type */
|
||||||
|
|
||||||
|
#define lowbit(x) ((x) & (~(x) + 1))
|
||||||
|
#define TRUEMATCH(mult,max,mask) \
|
||||||
|
(colormap->max * colormap->mult <= vinfo->mask && \
|
||||||
|
lowbit(vinfo->mask) == colormap->mult)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* To create any one colormap which is described by an XStandardColormap
|
||||||
|
* structure, use XmuCreateColormap().
|
||||||
|
*
|
||||||
|
* Return 0 on failure, non-zero on success.
|
||||||
|
* Resources created by this function are not made permanent.
|
||||||
|
* No argument error checking is provided. Use at your own risk.
|
||||||
|
*
|
||||||
|
* All colormaps are created with read only allocations, with the exception
|
||||||
|
* of read only allocations of colors in the default map or otherwise
|
||||||
|
* which fail to return the expected pixel value, and these are individually
|
||||||
|
* defined as read/write allocations. This is done so that all the cells
|
||||||
|
* defined in the default map are contiguous, for use in image processing.
|
||||||
|
* This typically happens with White and Black in the default map.
|
||||||
|
*
|
||||||
|
* Colormaps of static visuals are considered to be successfully created if
|
||||||
|
* the map of the static visual matches the definition given in the
|
||||||
|
* standard colormap structure.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Status XmuCreateColormap(dpy, colormap)
|
||||||
|
Display *dpy; /* specifies the connection under
|
||||||
|
* which the map is created */
|
||||||
|
XStandardColormap *colormap; /* specifies the map to be created,
|
||||||
|
* and returns, particularly if the
|
||||||
|
* map is created as a subset of the
|
||||||
|
* default colormap of the screen,
|
||||||
|
* the base_pixel of the map.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
XVisualInfo vinfo_template; /* template visual information */
|
||||||
|
XVisualInfo *vinfo; /* matching visual information */
|
||||||
|
XVisualInfo *vpointer; /* for freeing the entire list */
|
||||||
|
long vinfo_mask; /* specifies the visual mask value */
|
||||||
|
int n; /* number of matching visuals */
|
||||||
|
int status;
|
||||||
|
|
||||||
|
vinfo_template.visualid = colormap->visualid;
|
||||||
|
vinfo_mask = VisualIDMask;
|
||||||
|
if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* A visual id may be valid on multiple screens. Also, there may
|
||||||
|
* be multiple visuals with identical visual ids at different depths.
|
||||||
|
* If the colormap is the Default Colormap, use the Default Visual.
|
||||||
|
* Otherwise, arbitrarily, use the deepest visual.
|
||||||
|
*/
|
||||||
|
vpointer = vinfo;
|
||||||
|
if (n > 1)
|
||||||
|
{
|
||||||
|
register int i;
|
||||||
|
register int screen_number;
|
||||||
|
Bool def_cmap;
|
||||||
|
|
||||||
|
def_cmap = False;
|
||||||
|
for (screen_number = ScreenCount(dpy); --screen_number >= 0; )
|
||||||
|
if (colormap->colormap == DefaultColormap(dpy, screen_number)) {
|
||||||
|
def_cmap = True;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (def_cmap) {
|
||||||
|
for (i=0; i < n; i++, vinfo++) {
|
||||||
|
if (vinfo->visual == DefaultVisual(dpy, screen_number))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unsigned int maxdepth = 0;
|
||||||
|
XVisualInfo *v;
|
||||||
|
|
||||||
|
for (i=0; i < n; i++, vinfo++)
|
||||||
|
if (vinfo->depth > maxdepth) {
|
||||||
|
maxdepth = vinfo->depth;
|
||||||
|
v = vinfo;
|
||||||
|
}
|
||||||
|
vinfo = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vinfo->class == PseudoColor || vinfo->class == DirectColor ||
|
||||||
|
vinfo->class == GrayScale)
|
||||||
|
status = readwrite_map(dpy, vinfo, colormap);
|
||||||
|
else if (vinfo->class == TrueColor)
|
||||||
|
status = TRUEMATCH(red_mult, red_max, red_mask) &&
|
||||||
|
TRUEMATCH(green_mult, green_max, green_mask) &&
|
||||||
|
TRUEMATCH(blue_mult, blue_max, blue_mask);
|
||||||
|
else
|
||||||
|
status = readonly_map(dpy, vinfo, colormap);
|
||||||
|
|
||||||
|
XFree((char *) vpointer);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
static Status readwrite_map(dpy, vinfo, colormap)
|
||||||
|
Display *dpy;
|
||||||
|
XVisualInfo *vinfo;
|
||||||
|
XStandardColormap *colormap;
|
||||||
|
{
|
||||||
|
register unsigned long i, n; /* index counters */
|
||||||
|
int ncolors; /* number of colors to be defined */
|
||||||
|
int npixels; /* number of pixels allocated R/W */
|
||||||
|
int first_index; /* first index of pixels to use */
|
||||||
|
int remainder; /* first index of remainder */
|
||||||
|
XColor color; /* the definition of a color */
|
||||||
|
unsigned long *pixels; /* array of colormap pixels */
|
||||||
|
unsigned long delta;
|
||||||
|
|
||||||
|
|
||||||
|
/* Determine ncolors, the number of colors to be defined.
|
||||||
|
* Insure that 1 < ncolors <= the colormap size.
|
||||||
|
*/
|
||||||
|
if (vinfo->class == DirectColor) {
|
||||||
|
ncolors = colormap->red_max;
|
||||||
|
if (colormap->green_max > ncolors)
|
||||||
|
ncolors = colormap->green_max;
|
||||||
|
if (colormap->blue_max > ncolors)
|
||||||
|
ncolors = colormap->blue_max;
|
||||||
|
ncolors++;
|
||||||
|
delta = lowbit(vinfo->red_mask) +
|
||||||
|
lowbit(vinfo->green_mask) +
|
||||||
|
lowbit(vinfo->blue_mask);
|
||||||
|
} else {
|
||||||
|
ncolors = colormap->red_max * colormap->red_mult +
|
||||||
|
colormap->green_max * colormap->green_mult +
|
||||||
|
colormap->blue_max * colormap->blue_mult + 1;
|
||||||
|
delta = 1;
|
||||||
|
}
|
||||||
|
if (ncolors <= 1 || ncolors > vinfo->colormap_size) return 0;
|
||||||
|
|
||||||
|
/* Allocate Read/Write as much of the colormap as we can possibly get.
|
||||||
|
* Then insure that the pixels we were allocated are given in
|
||||||
|
* monotonically increasing order, using a quicksort. Next, insure
|
||||||
|
* that our allocation includes a subset of contiguous pixels at least
|
||||||
|
* as long as the number of colors to be defined. Now we know that
|
||||||
|
* these conditions are met:
|
||||||
|
* 1) There are no free cells in the colormap.
|
||||||
|
* 2) We have a contiguous sequence of pixels, monotonically
|
||||||
|
* increasing, of length >= the number of colors requested.
|
||||||
|
*
|
||||||
|
* One cell at a time, we will free, compute the next color value,
|
||||||
|
* then allocate read only. This takes a long time.
|
||||||
|
* This is done to insure that cells are allocated read only in the
|
||||||
|
* contiguous order which we prefer. If the server has a choice of
|
||||||
|
* cells to grant to an allocation request, the server may give us any
|
||||||
|
* cell, so that is why we do these slow gymnastics.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ((pixels = (unsigned long *) calloc((unsigned) vinfo->colormap_size,
|
||||||
|
sizeof(unsigned long))) == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if ((npixels = ROmap(dpy, colormap->colormap, pixels,
|
||||||
|
vinfo->colormap_size, ncolors)) == 0) {
|
||||||
|
free((char *) pixels);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
qsort((char *) pixels, npixels, sizeof(unsigned long), compare);
|
||||||
|
|
||||||
|
if (!contiguous(pixels, npixels, ncolors, delta, &first_index, &remainder))
|
||||||
|
{
|
||||||
|
/* can't find enough contiguous cells, give up */
|
||||||
|
XFreeColors(dpy, colormap->colormap, pixels, npixels,
|
||||||
|
(unsigned long) 0);
|
||||||
|
free((char *) pixels);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
colormap->base_pixel = pixels[first_index];
|
||||||
|
|
||||||
|
/* construct a gray map */
|
||||||
|
if (colormap->red_mult == 1 && colormap->green_mult == 1 &&
|
||||||
|
colormap->blue_mult == 1)
|
||||||
|
for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta)
|
||||||
|
{
|
||||||
|
color.pixel = n;
|
||||||
|
color.blue = color.green = color.red =
|
||||||
|
(unsigned short) ((i * 65535) / (colormap->red_max +
|
||||||
|
colormap->green_max +
|
||||||
|
colormap->blue_max));
|
||||||
|
|
||||||
|
if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
|
||||||
|
first_index + i))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* construct a red ramp map */
|
||||||
|
else if (colormap->green_max == 0 && colormap->blue_max == 0)
|
||||||
|
for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta)
|
||||||
|
{
|
||||||
|
color.pixel = n;
|
||||||
|
color.red = (unsigned short) ((i * 65535) / colormap->red_max);
|
||||||
|
color.green = color.blue = 0;
|
||||||
|
|
||||||
|
if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
|
||||||
|
first_index + i))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* construct a green ramp map */
|
||||||
|
else if (colormap->red_max == 0 && colormap->blue_max == 0)
|
||||||
|
for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta)
|
||||||
|
{
|
||||||
|
color.pixel = n;
|
||||||
|
color.green = (unsigned short) ((i * 65535) / colormap->green_max);
|
||||||
|
color.red = color.blue = 0;
|
||||||
|
|
||||||
|
if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
|
||||||
|
first_index + i))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* construct a blue ramp map */
|
||||||
|
else if (colormap->red_max == 0 && colormap->green_max == 0)
|
||||||
|
for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta)
|
||||||
|
{
|
||||||
|
color.pixel = n;
|
||||||
|
color.blue = (unsigned short) ((i * 65535) / colormap->blue_max);
|
||||||
|
color.red = color.green = 0;
|
||||||
|
|
||||||
|
if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
|
||||||
|
first_index + i))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* construct a standard red green blue cube map */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#define calc(max,mult) (((n / colormap->mult) % \
|
||||||
|
(colormap->max + 1)) * 65535) / colormap->max
|
||||||
|
|
||||||
|
for (n=0, i=0; i < ncolors; i++, n += delta)
|
||||||
|
{
|
||||||
|
color.pixel = n + colormap->base_pixel;
|
||||||
|
color.red = calc(red_max, red_mult);
|
||||||
|
color.green = calc(green_max, green_mult);
|
||||||
|
color.blue = calc(blue_max, blue_mult);
|
||||||
|
if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
|
||||||
|
first_index + i))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#undef calc
|
||||||
|
}
|
||||||
|
/* We have a read-only map defined. Now free unused cells,
|
||||||
|
* first those occuring before the contiguous sequence begins,
|
||||||
|
* then any following the contiguous sequence.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (first_index)
|
||||||
|
XFreeColors(dpy, colormap->colormap, pixels, first_index,
|
||||||
|
(unsigned long) 0);
|
||||||
|
if (remainder)
|
||||||
|
XFreeColors(dpy, colormap->colormap,
|
||||||
|
&(pixels[first_index + ncolors]), remainder,
|
||||||
|
(unsigned long) 0);
|
||||||
|
|
||||||
|
free((char *) pixels);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
static int ROmap(dpy, cmap, pixels, m, n)
|
||||||
|
Display *dpy; /* the X server connection */
|
||||||
|
Colormap cmap; /* specifies colormap ID */
|
||||||
|
unsigned long pixels[]; /* returns pixel allocations */
|
||||||
|
int m; /* specifies colormap size */
|
||||||
|
int n; /* specifies number of colors */
|
||||||
|
{
|
||||||
|
register int p;
|
||||||
|
|
||||||
|
/* first try to allocate the entire colormap */
|
||||||
|
if (XAllocColorCells(dpy, cmap, 1, (unsigned long *) NULL,
|
||||||
|
(unsigned) 0, pixels, (unsigned) m))
|
||||||
|
return m;
|
||||||
|
|
||||||
|
/* Allocate all available cells in the colormap, using a binary
|
||||||
|
* algorithm to discover how many cells we can allocate in the colormap.
|
||||||
|
*/
|
||||||
|
m--;
|
||||||
|
while (n <= m) {
|
||||||
|
p = n + ((m - n + 1) / 2);
|
||||||
|
if (XAllocColorCells(dpy, cmap, 1, (unsigned long *) NULL,
|
||||||
|
(unsigned) 0, pixels, (unsigned) p)) {
|
||||||
|
if (p == m)
|
||||||
|
return p;
|
||||||
|
else {
|
||||||
|
XFreeColors(dpy, cmap, pixels, p, (unsigned long) 0);
|
||||||
|
n = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m = p - 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
static Status contiguous(pixels, npixels, ncolors, delta, first, rem)
|
||||||
|
unsigned long pixels[]; /* specifies allocated pixels */
|
||||||
|
int npixels; /* specifies count of alloc'd pixels */
|
||||||
|
int ncolors; /* specifies needed sequence length */
|
||||||
|
unsigned long delta; /* between pixels */
|
||||||
|
int *first; /* returns first index of sequence */
|
||||||
|
int *rem; /* returns first index after sequence,
|
||||||
|
* or 0, if none follow */
|
||||||
|
{
|
||||||
|
register int i = 1; /* walking index into the pixel array */
|
||||||
|
register int count = 1; /* length of sequence discovered so far */
|
||||||
|
|
||||||
|
*first = 0;
|
||||||
|
if (npixels == ncolors) {
|
||||||
|
*rem = 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
*rem = npixels - 1;
|
||||||
|
while (count < ncolors && ncolors - count <= *rem)
|
||||||
|
{
|
||||||
|
if (pixels[i-1] + delta == pixels[i])
|
||||||
|
count++;
|
||||||
|
else {
|
||||||
|
count = 1;
|
||||||
|
*first = i;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
(*rem)--;
|
||||||
|
}
|
||||||
|
if (count != ncolors)
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
static Status ROorRWcell(dpy, cmap, pixels, npixels, color, p)
|
||||||
|
Display *dpy;
|
||||||
|
Colormap cmap;
|
||||||
|
unsigned long pixels[];
|
||||||
|
int npixels;
|
||||||
|
XColor *color;
|
||||||
|
unsigned long p;
|
||||||
|
{
|
||||||
|
unsigned long pixel;
|
||||||
|
XColor request;
|
||||||
|
|
||||||
|
/* Free the read/write allocation of one cell in the colormap.
|
||||||
|
* Request a read only allocation of one cell in the colormap.
|
||||||
|
* If the read only allocation cannot be granted, give up, because
|
||||||
|
* there must be no free cells in the colormap.
|
||||||
|
* If the read only allocation is granted, but gives us a cell which
|
||||||
|
* is not the one that we just freed, it is probably the case that
|
||||||
|
* we are trying allocate White or Black or some other color which
|
||||||
|
* already has a read-only allocation in the map. So we try to
|
||||||
|
* allocate the previously freed cell with a read/write allocation,
|
||||||
|
* because we want contiguous cells for image processing algorithms.
|
||||||
|
*/
|
||||||
|
|
||||||
|
pixel = color->pixel;
|
||||||
|
request.red = color->red;
|
||||||
|
request.green = color->green;
|
||||||
|
request.blue = color->blue;
|
||||||
|
|
||||||
|
XFreeColors(dpy, cmap, &pixel, 1, (unsigned long) 0);
|
||||||
|
if (! XAllocColor(dpy, cmap, color)
|
||||||
|
|| (color->pixel != pixel &&
|
||||||
|
(!RWcell(dpy, cmap, color, &request, &pixel))))
|
||||||
|
{
|
||||||
|
free_cells(dpy, cmap, pixels, npixels, (int)p);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
static void free_cells(dpy, cmap, pixels, npixels, p)
|
||||||
|
Display *dpy;
|
||||||
|
Colormap cmap;
|
||||||
|
unsigned long pixels[]; /* to be freed */
|
||||||
|
int npixels; /* original number allocated */
|
||||||
|
int p;
|
||||||
|
{
|
||||||
|
/* One of the npixels allocated has already been freed.
|
||||||
|
* p is the index of the freed pixel.
|
||||||
|
* First free the pixels preceeding p, and there are p of them;
|
||||||
|
* then free the pixels following p, there are npixels - p - 1 of them.
|
||||||
|
*/
|
||||||
|
XFreeColors(dpy, cmap, pixels, p, (unsigned long) 0);
|
||||||
|
XFreeColors(dpy, cmap, &(pixels[p+1]), npixels - p - 1, (unsigned long) 0);
|
||||||
|
free((char *) pixels);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
static Status RWcell(dpy, cmap, color, request, pixel)
|
||||||
|
Display *dpy;
|
||||||
|
Colormap cmap;
|
||||||
|
XColor *color;
|
||||||
|
XColor *request;
|
||||||
|
unsigned long *pixel;
|
||||||
|
{
|
||||||
|
unsigned long n = *pixel;
|
||||||
|
|
||||||
|
XFreeColors(dpy, cmap, &(color->pixel), 1, (unsigned long)0);
|
||||||
|
if (! XAllocColorCells(dpy, cmap, (Bool) 0, (unsigned long *) NULL,
|
||||||
|
(unsigned) 0, pixel, (unsigned) 1))
|
||||||
|
return 0;
|
||||||
|
if (*pixel != n)
|
||||||
|
{
|
||||||
|
XFreeColors(dpy, cmap, pixel, 1, (unsigned long) 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
color->pixel = *pixel;
|
||||||
|
color->flags = DoRed | DoGreen | DoBlue;
|
||||||
|
color->red = request->red;
|
||||||
|
color->green = request->green;
|
||||||
|
color->blue = request->blue;
|
||||||
|
XStoreColors(dpy, cmap, color, 1);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
static int compare(e1, e2)
|
||||||
|
unsigned long *e1, *e2;
|
||||||
|
{
|
||||||
|
if (*e1 < *e2) return -1;
|
||||||
|
if (*e1 > *e2) return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
static Status readonly_map(dpy, vinfo, colormap)
|
||||||
|
Display *dpy;
|
||||||
|
XVisualInfo *vinfo;
|
||||||
|
XStandardColormap *colormap;
|
||||||
|
{
|
||||||
|
int i, last_pixel;
|
||||||
|
XColor color;
|
||||||
|
|
||||||
|
last_pixel = (colormap->red_max + 1) * (colormap->green_max + 1) *
|
||||||
|
(colormap->blue_max + 1) + colormap->base_pixel - 1;
|
||||||
|
|
||||||
|
for(i=colormap->base_pixel; i <= last_pixel; i++) {
|
||||||
|
|
||||||
|
color.pixel = (unsigned long) i;
|
||||||
|
color.red = (unsigned short)
|
||||||
|
(((i/colormap->red_mult) * 65535) / colormap->red_max);
|
||||||
|
|
||||||
|
if (vinfo->class == StaticColor) {
|
||||||
|
color.green = (unsigned short)
|
||||||
|
((((i/colormap->green_mult) % (colormap->green_max + 1)) *
|
||||||
|
65535) / colormap->green_max);
|
||||||
|
color.blue = (unsigned short)
|
||||||
|
(((i%colormap->green_mult) * 65535) / colormap->blue_max);
|
||||||
|
}
|
||||||
|
else /* vinfo->class == GrayScale, old style allocation XXX */
|
||||||
|
color.green = color.blue = color.red;
|
||||||
|
|
||||||
|
XAllocColor(dpy, colormap->colormap, &color);
|
||||||
|
if (color.pixel != (unsigned long) i)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
67
ng/Togl2.1/Xmu/DelCmap.c
Normal file
67
ng/Togl2.1/Xmu/DelCmap.c
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/* $XConsortium: DelCmap.c,v 1.2 94/04/17 20:15:58 converse Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 1989 X Consortium
|
||||||
|
|
||||||
|
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 THE
|
||||||
|
X CONSORTIUM 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 X Consortium 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 X Consortium.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Author: Donna Converse, MIT X Consortium
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
|
/* To remove any standard colormap property, use XmuDeleteStandardColormap().
|
||||||
|
* XmuDeleteStandardColormap() will remove the specified property from the
|
||||||
|
* specified screen, releasing any resources used by the colormap(s) of the
|
||||||
|
* property if possible.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void XmuDeleteStandardColormap(dpy, screen, property)
|
||||||
|
Display *dpy; /* specifies the X server to connect to */
|
||||||
|
int screen; /* specifies the screen of the display */
|
||||||
|
Atom property; /* specifies the standard colormap property */
|
||||||
|
{
|
||||||
|
XStandardColormap *stdcmaps, *s;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
if (XGetRGBColormaps(dpy, RootWindow(dpy, screen), &stdcmaps, &count,
|
||||||
|
property))
|
||||||
|
{
|
||||||
|
for (s=stdcmaps; count > 0; count--, s++) {
|
||||||
|
if ((s->killid == ReleaseByFreeingColormap) &&
|
||||||
|
(s->colormap != None) &&
|
||||||
|
(s->colormap != DefaultColormap(dpy, screen)))
|
||||||
|
XFreeColormap(dpy, s->colormap);
|
||||||
|
else if (s->killid != None)
|
||||||
|
XKillClient(dpy, s->killid);
|
||||||
|
}
|
||||||
|
XDeleteProperty(dpy, RootWindow(dpy, screen), property);
|
||||||
|
XFree((char *) stdcmaps);
|
||||||
|
XSync(dpy, False);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
311
ng/Togl2.1/Xmu/LookupCmap.c
Normal file
311
ng/Togl2.1/Xmu/LookupCmap.c
Normal file
@ -0,0 +1,311 @@
|
|||||||
|
/* $XConsortium: LookupCmap.c,v 1.10 94/04/17 20:16:11 rws Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 1989 X Consortium
|
||||||
|
|
||||||
|
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 THE
|
||||||
|
X CONSORTIUM 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 X Consortium 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 X Consortium.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Author: Donna Converse, MIT X Consortium
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xatom.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
#include <X11/Xmu/StdCmap.h>
|
||||||
|
|
||||||
|
static Status lookup();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* To create a standard colormap if one does not currently exist, or
|
||||||
|
* replace the currently existing standard colormap, use
|
||||||
|
* XmuLookupStandardColormap().
|
||||||
|
*
|
||||||
|
* Given a screen, a visual, and a property, XmuLookupStandardColormap()
|
||||||
|
* will determine the best allocation for the property under the specified
|
||||||
|
* visual, and determine the whether to create a new colormap or to use
|
||||||
|
* the default colormap of the screen. It will call XmuStandardColormap()
|
||||||
|
* to create the standard colormap.
|
||||||
|
*
|
||||||
|
* If replace is true, any previous definition of the property will be
|
||||||
|
* replaced. If retain is true, the property and the colormap will be
|
||||||
|
* made permanent for the duration of the server session. However,
|
||||||
|
* pre-existing property definitions which are not replaced cannot be made
|
||||||
|
* permanent by a call to XmuLookupStandardColormap(); a request to retain
|
||||||
|
* resources pertains to newly created resources.
|
||||||
|
*
|
||||||
|
* Returns 0 on failure, non-zero on success. A request to create a
|
||||||
|
* standard colormap upon a visual which cannot support such a map is
|
||||||
|
* considered a failure. An example of this would be requesting any
|
||||||
|
* standard colormap property on a monochrome visual, or, requesting an
|
||||||
|
* RGB_BEST_MAP on a display whose colormap size is 16.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Status XmuLookupStandardColormap(dpy, screen, visualid, depth, property,
|
||||||
|
replace, retain)
|
||||||
|
Display *dpy; /* specifies X server connection */
|
||||||
|
int screen; /* specifies screen of display */
|
||||||
|
VisualID visualid; /* specifies the visual type */
|
||||||
|
unsigned int depth; /* specifies the visual type */
|
||||||
|
Atom property; /* a standard colormap property */
|
||||||
|
Bool replace; /* specifies whether to replace */
|
||||||
|
Bool retain; /* specifies whether to retain */
|
||||||
|
{
|
||||||
|
Display *odpy; /* original display connection */
|
||||||
|
XStandardColormap *colormap;
|
||||||
|
XVisualInfo vinfo_template, *vinfo; /* visual */
|
||||||
|
long vinfo_mask;
|
||||||
|
unsigned long r_max, g_max, b_max; /* allocation */
|
||||||
|
int count;
|
||||||
|
Colormap cmap; /* colormap ID */
|
||||||
|
Status status = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/* Match the requested visual */
|
||||||
|
|
||||||
|
vinfo_template.visualid = visualid;
|
||||||
|
vinfo_template.screen = screen;
|
||||||
|
vinfo_template.depth = depth;
|
||||||
|
vinfo_mask = VisualIDMask | VisualScreenMask | VisualDepthMask;
|
||||||
|
if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &count)) ==
|
||||||
|
NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Monochrome visuals have no standard maps */
|
||||||
|
|
||||||
|
if (vinfo->colormap_size <= 2) {
|
||||||
|
XFree((char *) vinfo);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the requested property already exists on this screen, and,
|
||||||
|
* if the replace flag has not been set to true, return success.
|
||||||
|
* lookup() will remove a pre-existing map if replace is true.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (lookup(dpy, screen, visualid, property, (XStandardColormap *) NULL,
|
||||||
|
replace) && !replace) {
|
||||||
|
XFree((char *) vinfo);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Determine the best allocation for this property under the requested
|
||||||
|
* visualid and depth, and determine whether or not to use the default
|
||||||
|
* colormap of the screen.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!XmuGetColormapAllocation(vinfo, property, &r_max, &g_max, &b_max)) {
|
||||||
|
XFree((char *) vinfo);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmap = (property == XA_RGB_DEFAULT_MAP &&
|
||||||
|
visualid == XVisualIDFromVisual(DefaultVisual(dpy, screen)))
|
||||||
|
? DefaultColormap(dpy, screen) : None;
|
||||||
|
|
||||||
|
/* If retaining resources, open a new connection to the same server */
|
||||||
|
|
||||||
|
if (retain) {
|
||||||
|
odpy = dpy;
|
||||||
|
if ((dpy = XOpenDisplay(XDisplayString(odpy))) == NULL) {
|
||||||
|
XFree((char *) vinfo);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create the standard colormap */
|
||||||
|
|
||||||
|
colormap = XmuStandardColormap(dpy, screen, visualid, depth, property,
|
||||||
|
cmap, r_max, g_max, b_max);
|
||||||
|
|
||||||
|
/* Set the standard colormap property */
|
||||||
|
|
||||||
|
if (colormap) {
|
||||||
|
XGrabServer(dpy);
|
||||||
|
|
||||||
|
if (lookup(dpy, screen, visualid, property, colormap, replace) &&
|
||||||
|
!replace) {
|
||||||
|
/* Someone has defined the property since we last looked.
|
||||||
|
* Since we will not replace it, release our own resources.
|
||||||
|
* If this is the default map, our allocations will be freed
|
||||||
|
* when this connection closes.
|
||||||
|
*/
|
||||||
|
if (colormap->killid == ReleaseByFreeingColormap)
|
||||||
|
XFreeColormap(dpy, colormap->colormap);
|
||||||
|
}
|
||||||
|
else if (retain) {
|
||||||
|
XSetCloseDownMode(dpy, RetainPermanent);
|
||||||
|
}
|
||||||
|
XUngrabServer(dpy);
|
||||||
|
XFree((char *) colormap);
|
||||||
|
status = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (retain)
|
||||||
|
XCloseDisplay(dpy);
|
||||||
|
XFree((char *) vinfo);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************/
|
||||||
|
|
||||||
|
/* Lookup a standard colormap property. If the property is RGB_DEFAULT_MAP,
|
||||||
|
* the visualid is used to determine whether the indicated standard colormap
|
||||||
|
* exists. If the map exists and replace is true, delete the resources used
|
||||||
|
* by the map and remove the property. Return true if the map exists,
|
||||||
|
* or did exist and was deleted; return false if the map was not found.
|
||||||
|
*
|
||||||
|
* Note that this is not the way that a Status return is normally used.
|
||||||
|
*
|
||||||
|
* If new is not NULL, new points to an XStandardColormap structure which
|
||||||
|
* describes a standard colormap of the specified property. It will be made
|
||||||
|
* a standard colormap of the screen if none already exists, or if replace
|
||||||
|
* is true.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static Status lookup(dpy, screen, visualid, property, new, replace)
|
||||||
|
Display *dpy; /* specifies display connection */
|
||||||
|
int screen; /* specifies screen number */
|
||||||
|
VisualID visualid; /* specifies visualid for std map */
|
||||||
|
Atom property; /* specifies colormap property name */
|
||||||
|
XStandardColormap *new; /* specifies a standard colormap */
|
||||||
|
Bool replace; /* specifies whether to replace */
|
||||||
|
{
|
||||||
|
register int i;
|
||||||
|
int count;
|
||||||
|
XStandardColormap *stdcmaps, *s;
|
||||||
|
Window win = RootWindow(dpy, screen);
|
||||||
|
|
||||||
|
/* The property does not already exist */
|
||||||
|
|
||||||
|
if (! XGetRGBColormaps(dpy, win, &stdcmaps, &count, property)) {
|
||||||
|
if (new)
|
||||||
|
XSetRGBColormaps(dpy, win, new, 1, property);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The property exists and is not describing the RGB_DEFAULT_MAP */
|
||||||
|
|
||||||
|
if (property != XA_RGB_DEFAULT_MAP) {
|
||||||
|
if (replace) {
|
||||||
|
XmuDeleteStandardColormap(dpy, screen, property);
|
||||||
|
if (new)
|
||||||
|
XSetRGBColormaps(dpy, win, new, 1, property);
|
||||||
|
}
|
||||||
|
XFree((char *)stdcmaps);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The property exists and is RGB_DEFAULT_MAP */
|
||||||
|
|
||||||
|
for (i=0, s=stdcmaps; (i < count) && (s->visualid != visualid); i++, s++)
|
||||||
|
;
|
||||||
|
|
||||||
|
/* No RGB_DEFAULT_MAP property matches the given visualid */
|
||||||
|
|
||||||
|
if (i == count) {
|
||||||
|
if (new) {
|
||||||
|
XStandardColormap *m, *maps;
|
||||||
|
|
||||||
|
s = (XStandardColormap *) malloc((unsigned) ((count+1) * sizeof
|
||||||
|
(XStandardColormap)));
|
||||||
|
|
||||||
|
for (i = 0, m = s, maps = stdcmaps; i < count; i++, m++, maps++) {
|
||||||
|
m->colormap = maps->colormap;
|
||||||
|
m->red_max = maps->red_max;
|
||||||
|
m->red_mult = maps->red_mult;
|
||||||
|
m->green_max = maps->green_max;
|
||||||
|
m->green_mult = maps->green_mult;
|
||||||
|
m->blue_max = maps->blue_max;
|
||||||
|
m->blue_mult = maps->blue_mult;
|
||||||
|
m->base_pixel = maps->base_pixel;
|
||||||
|
m->visualid = maps->visualid;
|
||||||
|
m->killid = maps->killid;
|
||||||
|
}
|
||||||
|
m->colormap = new->colormap;
|
||||||
|
m->red_max = new->red_max;
|
||||||
|
m->red_mult = new->red_mult;
|
||||||
|
m->green_max = new->green_max;
|
||||||
|
m->green_mult = new->green_mult;
|
||||||
|
m->blue_max = new->blue_max;
|
||||||
|
m->blue_mult = new->blue_mult;
|
||||||
|
m->base_pixel = new->base_pixel;
|
||||||
|
m->visualid = new->visualid;
|
||||||
|
m->killid = new->killid;
|
||||||
|
|
||||||
|
XSetRGBColormaps(dpy, win, s, ++count, property);
|
||||||
|
free((char *) s);
|
||||||
|
}
|
||||||
|
XFree((char *) stdcmaps);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Found an RGB_DEFAULT_MAP property with a matching visualid */
|
||||||
|
|
||||||
|
if (replace) {
|
||||||
|
/* Free old resources first - we may need them, particularly in
|
||||||
|
* the default colormap of the screen. However, because of this,
|
||||||
|
* it is possible that we will destroy the old resource and fail
|
||||||
|
* to create a new one if XmuStandardColormap() fails.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (count == 1) {
|
||||||
|
XmuDeleteStandardColormap(dpy, screen, property);
|
||||||
|
if (new)
|
||||||
|
XSetRGBColormaps(dpy, win, new, 1, property);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
XStandardColormap *map;
|
||||||
|
|
||||||
|
/* s still points to the matching standard colormap */
|
||||||
|
|
||||||
|
if (s->killid == ReleaseByFreeingColormap) {
|
||||||
|
if ((s->colormap != None) &&
|
||||||
|
(s->colormap != DefaultColormap(dpy, screen)))
|
||||||
|
XFreeColormap(dpy, s->colormap);
|
||||||
|
}
|
||||||
|
else if (s->killid != None)
|
||||||
|
XKillClient(dpy, s->killid);
|
||||||
|
|
||||||
|
map = (new) ? new : stdcmaps + --count;
|
||||||
|
|
||||||
|
s->colormap = map->colormap;
|
||||||
|
s->red_max = map->red_max;
|
||||||
|
s->red_mult = map->red_mult;
|
||||||
|
s->green_max = map->green_max;
|
||||||
|
s->green_mult = map->green_mult;
|
||||||
|
s->blue_max = map->blue_max;
|
||||||
|
s->blue_mult = map->blue_mult;
|
||||||
|
s->visualid = map->visualid;
|
||||||
|
s->killid = map->killid;
|
||||||
|
|
||||||
|
XSetRGBColormaps(dpy, win, stdcmaps, count, property);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
XFree((char *) stdcmaps);
|
||||||
|
return 1;
|
||||||
|
}
|
3
ng/Togl2.1/Xmu/README.togl
Normal file
3
ng/Togl2.1/Xmu/README.togl
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
The source code in this directory is a subset of the Jun 12, 1995 X11R6 Xmu
|
||||||
|
library that is needed for the Togl widget. The Xmu library is no longer
|
||||||
|
installed by default on many Linux systems.
|
219
ng/Togl2.1/Xmu/StdCmap.c
Normal file
219
ng/Togl2.1/Xmu/StdCmap.c
Normal file
@ -0,0 +1,219 @@
|
|||||||
|
/* $XConsortium: StdCmap.c,v 1.14 94/04/17 20:16:14 rws Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 1989 X Consortium
|
||||||
|
|
||||||
|
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 THE
|
||||||
|
X CONSORTIUM 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 X Consortium 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 X Consortium.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Author: Donna Converse, MIT X Consortium
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xatom.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
#include <X11/Xmu/StdCmap.h>
|
||||||
|
|
||||||
|
#define lowbit(x) ((x) & (~(x) + 1))
|
||||||
|
|
||||||
|
static Status valid_args(); /* argument restrictions */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* To create any one standard colormap, use XmuStandardColormap().
|
||||||
|
*
|
||||||
|
* Create a standard colormap for the given screen, visualid, and visual
|
||||||
|
* depth, with the given red, green, and blue maximum values, with the
|
||||||
|
* given standard property name. Return a pointer to an XStandardColormap
|
||||||
|
* structure which describes the newly created colormap, upon success.
|
||||||
|
* Upon failure, return NULL.
|
||||||
|
*
|
||||||
|
* XmuStandardColormap() calls XmuCreateColormap() to create the map.
|
||||||
|
*
|
||||||
|
* Resources created by this function are not made permanent; that is the
|
||||||
|
* caller's responsibility.
|
||||||
|
*/
|
||||||
|
|
||||||
|
XStandardColormap *XmuStandardColormap(dpy, screen, visualid, depth, property,
|
||||||
|
cmap, red_max, green_max, blue_max)
|
||||||
|
Display *dpy; /* specifies X server connection */
|
||||||
|
int screen; /* specifies display screen */
|
||||||
|
VisualID visualid; /* identifies the visual type */
|
||||||
|
unsigned int depth; /* identifies the visual type */
|
||||||
|
Atom property; /* a standard colormap property */
|
||||||
|
Colormap cmap; /* specifies colormap ID or None */
|
||||||
|
unsigned long red_max, green_max, blue_max; /* allocations */
|
||||||
|
{
|
||||||
|
XStandardColormap *stdcmap;
|
||||||
|
Status status;
|
||||||
|
XVisualInfo vinfo_template, *vinfo;
|
||||||
|
long vinfo_mask;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
/* Match the required visual information to an actual visual */
|
||||||
|
vinfo_template.visualid = visualid;
|
||||||
|
vinfo_template.screen = screen;
|
||||||
|
vinfo_template.depth = depth;
|
||||||
|
vinfo_mask = VisualIDMask | VisualScreenMask | VisualDepthMask;
|
||||||
|
if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Check the validity of the combination of visual characteristics,
|
||||||
|
* allocation, and colormap property. Create an XStandardColormap
|
||||||
|
* structure.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (! valid_args(vinfo, red_max, green_max, blue_max, property)
|
||||||
|
|| ((stdcmap = XAllocStandardColormap()) == NULL)) {
|
||||||
|
XFree((char *) vinfo);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fill in the XStandardColormap structure */
|
||||||
|
|
||||||
|
if (cmap == DefaultColormap(dpy, screen)) {
|
||||||
|
/* Allocating out of the default map, cannot use XFreeColormap() */
|
||||||
|
Window win = XCreateWindow(dpy, RootWindow(dpy, screen), 1, 1, 1, 1,
|
||||||
|
0, 0, InputOnly, vinfo->visual,
|
||||||
|
(unsigned long) 0,
|
||||||
|
(XSetWindowAttributes *)NULL);
|
||||||
|
stdcmap->killid = (XID) XCreatePixmap(dpy, win, 1, 1, depth);
|
||||||
|
XDestroyWindow(dpy, win);
|
||||||
|
stdcmap->colormap = cmap;
|
||||||
|
} else {
|
||||||
|
stdcmap->killid = ReleaseByFreeingColormap;
|
||||||
|
stdcmap->colormap = XCreateColormap(dpy, RootWindow(dpy, screen),
|
||||||
|
vinfo->visual, AllocNone);
|
||||||
|
}
|
||||||
|
stdcmap->red_max = red_max;
|
||||||
|
stdcmap->green_max = green_max;
|
||||||
|
stdcmap->blue_max = blue_max;
|
||||||
|
if (property == XA_RGB_GRAY_MAP)
|
||||||
|
stdcmap->red_mult = stdcmap->green_mult = stdcmap->blue_mult = 1;
|
||||||
|
else if (vinfo->class == TrueColor || vinfo->class == DirectColor) {
|
||||||
|
stdcmap->red_mult = lowbit(vinfo->red_mask);
|
||||||
|
stdcmap->green_mult = lowbit(vinfo->green_mask);
|
||||||
|
stdcmap->blue_mult = lowbit(vinfo->blue_mask);
|
||||||
|
} else {
|
||||||
|
stdcmap->red_mult = (red_max > 0)
|
||||||
|
? (green_max + 1) * (blue_max + 1) : 0;
|
||||||
|
stdcmap->green_mult = (green_max > 0) ? blue_max + 1 : 0;
|
||||||
|
stdcmap->blue_mult = (blue_max > 0) ? 1 : 0;
|
||||||
|
}
|
||||||
|
stdcmap->base_pixel = 0; /* base pixel may change */
|
||||||
|
stdcmap->visualid = vinfo->visualid;
|
||||||
|
|
||||||
|
/* Make the colormap */
|
||||||
|
|
||||||
|
status = XmuCreateColormap(dpy, stdcmap);
|
||||||
|
|
||||||
|
/* Clean up */
|
||||||
|
|
||||||
|
XFree((char *) vinfo);
|
||||||
|
if (!status) {
|
||||||
|
|
||||||
|
/* Free the colormap or the pixmap, if we created one */
|
||||||
|
if (stdcmap->killid == ReleaseByFreeingColormap)
|
||||||
|
XFreeColormap(dpy, stdcmap->colormap);
|
||||||
|
else if (stdcmap->killid != None)
|
||||||
|
XFreePixmap(dpy, stdcmap->killid);
|
||||||
|
|
||||||
|
XFree((char *) stdcmap);
|
||||||
|
return (XStandardColormap *) NULL;
|
||||||
|
}
|
||||||
|
return stdcmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
static Status valid_args(vinfo, red_max, green_max, blue_max, property)
|
||||||
|
XVisualInfo *vinfo; /* specifies visual */
|
||||||
|
unsigned long red_max, green_max, blue_max; /* specifies alloc */
|
||||||
|
Atom property; /* specifies property name */
|
||||||
|
{
|
||||||
|
unsigned long ncolors; /* number of colors requested */
|
||||||
|
|
||||||
|
/* Determine that the number of colors requested is <= map size */
|
||||||
|
|
||||||
|
if ((vinfo->class == DirectColor) || (vinfo->class == TrueColor)) {
|
||||||
|
unsigned long mask;
|
||||||
|
|
||||||
|
mask = vinfo->red_mask;
|
||||||
|
while (!(mask & 1))
|
||||||
|
mask >>= 1;
|
||||||
|
if (red_max > mask)
|
||||||
|
return 0;
|
||||||
|
mask = vinfo->green_mask;
|
||||||
|
while (!(mask & 1))
|
||||||
|
mask >>= 1;
|
||||||
|
if (green_max > mask)
|
||||||
|
return 0;
|
||||||
|
mask = vinfo->blue_mask;
|
||||||
|
while (!(mask & 1))
|
||||||
|
mask >>= 1;
|
||||||
|
if (blue_max > mask)
|
||||||
|
return 0;
|
||||||
|
} else if (property == XA_RGB_GRAY_MAP) {
|
||||||
|
ncolors = red_max + green_max + blue_max + 1;
|
||||||
|
if (ncolors > vinfo->colormap_size)
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
ncolors = (red_max + 1) * (green_max + 1) * (blue_max + 1);
|
||||||
|
if (ncolors > vinfo->colormap_size)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Determine that the allocation and visual make sense for the property */
|
||||||
|
|
||||||
|
switch (property)
|
||||||
|
{
|
||||||
|
case XA_RGB_DEFAULT_MAP:
|
||||||
|
if (red_max == 0 || green_max == 0 || blue_max == 0)
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case XA_RGB_RED_MAP:
|
||||||
|
if (red_max == 0)
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case XA_RGB_GREEN_MAP:
|
||||||
|
if (green_max == 0)
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case XA_RGB_BLUE_MAP:
|
||||||
|
if (blue_max == 0)
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case XA_RGB_BEST_MAP:
|
||||||
|
if (red_max == 0 || green_max == 0 || blue_max == 0)
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case XA_RGB_GRAY_MAP:
|
||||||
|
if (red_max == 0 || blue_max == 0 || green_max == 0)
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
112
ng/Togl2.1/Xmu/StdCmap.h
Normal file
112
ng/Togl2.1/Xmu/StdCmap.h
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
/* $XConsortium: StdCmap.h,v 1.4 94/04/17 20:16:15 converse Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 1988 X Consortium
|
||||||
|
|
||||||
|
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 THE
|
||||||
|
X CONSORTIUM 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 X Consortium 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 X Consortium.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The interfaces described by this header file are for miscellaneous utilities
|
||||||
|
* and are not part of the Xlib standard.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _XMU_STDCMAP_H_
|
||||||
|
#define _XMU_STDCMAP_H_
|
||||||
|
|
||||||
|
#include <X11/Xfuncproto.h>
|
||||||
|
|
||||||
|
_XFUNCPROTOBEGIN
|
||||||
|
|
||||||
|
Status XmuAllStandardColormaps(
|
||||||
|
#if NeedFunctionPrototypes
|
||||||
|
Display* /* dpy */
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
|
Status XmuCreateColormap(
|
||||||
|
#if NeedFunctionPrototypes
|
||||||
|
Display* /* dpy */,
|
||||||
|
XStandardColormap* /* colormap */
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
|
void XmuDeleteStandardColormap(
|
||||||
|
#if NeedFunctionPrototypes
|
||||||
|
Display* /* dpy */,
|
||||||
|
int /* screen */,
|
||||||
|
Atom /* property */
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
|
Status XmuGetColormapAllocation(
|
||||||
|
#if NeedFunctionPrototypes
|
||||||
|
XVisualInfo* /* vinfo */,
|
||||||
|
Atom /* property */,
|
||||||
|
unsigned long* /* red_max_return */,
|
||||||
|
unsigned long* /* green_max_return */,
|
||||||
|
unsigned long* /* blue_max_return */
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
|
Status XmuLookupStandardColormap(
|
||||||
|
#if NeedFunctionPrototypes
|
||||||
|
Display* /* dpy */,
|
||||||
|
int /* screen */,
|
||||||
|
VisualID /* visualid */,
|
||||||
|
unsigned int /* depth */,
|
||||||
|
Atom /* property */,
|
||||||
|
Bool /* replace */,
|
||||||
|
Bool /* retain */
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
|
XStandardColormap *XmuStandardColormap(
|
||||||
|
#if NeedFunctionPrototypes
|
||||||
|
Display* /* dpy */,
|
||||||
|
int /* screen */,
|
||||||
|
VisualID /* visualid */,
|
||||||
|
unsigned int /* depth */,
|
||||||
|
Atom /* property */,
|
||||||
|
Colormap /* cmap */,
|
||||||
|
unsigned long /* red_max */,
|
||||||
|
unsigned long /* green_max */,
|
||||||
|
unsigned long /* blue_max */
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
|
Status XmuVisualStandardColormaps(
|
||||||
|
#if NeedFunctionPrototypes
|
||||||
|
Display* /* dpy */,
|
||||||
|
int /* screen */,
|
||||||
|
VisualID /* visualid */,
|
||||||
|
unsigned int /* depth */,
|
||||||
|
Bool /* replace */,
|
||||||
|
Bool /* retain */
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
|
_XFUNCPROTOEND
|
||||||
|
|
||||||
|
#endif /* _XMU_STDCMAP_H_ */
|
80
ng/Togl2.1/aclocal.m4
vendored
Normal file
80
ng/Togl2.1/aclocal.m4
vendored
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
#
|
||||||
|
# Include the TEA standard macro set
|
||||||
|
#
|
||||||
|
|
||||||
|
builtin(include,tclconfig/tcl.m4)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Add here whatever m4 macros you want to define for your package
|
||||||
|
#
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
# TOGL_ENABLE_STUBS --
|
||||||
|
#
|
||||||
|
# Specifiy if stubs should be used.
|
||||||
|
#
|
||||||
|
# Arguments:
|
||||||
|
# none
|
||||||
|
#
|
||||||
|
# Results:
|
||||||
|
#
|
||||||
|
# Adds the following arguments to configure:
|
||||||
|
# --enable-stubs
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
AC_DEFUN(TOGL_ENABLE_STUBS, [
|
||||||
|
AC_MSG_CHECKING([whether to link with stubs library])
|
||||||
|
AC_ARG_ENABLE(stubs,
|
||||||
|
[ --enable-stubs build and link with stub libraries (--enable-stubs)],
|
||||||
|
[tcl_ok=$enableval], [tcl_ok=yes])
|
||||||
|
|
||||||
|
if test "${enable_stubs+set}" = set; then
|
||||||
|
enableval="$enable_stubs"
|
||||||
|
tcl_ok=$enableval
|
||||||
|
else
|
||||||
|
tcl_ok=yes
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "$tcl_ok" = "yes" ; then
|
||||||
|
AC_MSG_RESULT([stubs])
|
||||||
|
USE_STUBS=1
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT([no stubs])
|
||||||
|
USE_STUBS=0
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
# TOGL_UNDEF_GET_PROC_ADDRESS --
|
||||||
|
#
|
||||||
|
# Does defining GLX_GLXEXT_LEGACY interfer with including GL/glxext.h?
|
||||||
|
#
|
||||||
|
# Arguments:
|
||||||
|
# none
|
||||||
|
#
|
||||||
|
# Results:
|
||||||
|
#
|
||||||
|
# defines TOGL_UNDEF_GET_PROC_ADDRESS
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
AC_DEFUN(TOGL_UNDEF_GET_PROC_ADDRESS, [
|
||||||
|
AC_MSG_CHECKING([if GLX_GLXEXT_LEGACY interfers with including GL/glxext.h])
|
||||||
|
AC_LANG_PUSH(C)
|
||||||
|
ac_save_CFLAGS=$CFLAGS
|
||||||
|
CFLAGS=$TK_XINCLUDES
|
||||||
|
AC_COMPILE_IFELSE(
|
||||||
|
[AC_LANG_SOURCE([[
|
||||||
|
#define GLX_GLXEXT_LEGACY
|
||||||
|
#include <GL/glx.h>
|
||||||
|
#undef GLX_VERSION_1_3
|
||||||
|
#undef GLX_VERSION_1_4
|
||||||
|
#include <GL/glxext.h>
|
||||||
|
int main() { return 0; }
|
||||||
|
]])],
|
||||||
|
[AC_MSG_RESULT([no])],
|
||||||
|
[AC_MSG_RESULT([yes])
|
||||||
|
AC_DEFINE(UNDEF_GET_PROC_ADDRESS, 1)])
|
||||||
|
CFLAGS=$ac_save_CFLAGS
|
||||||
|
AC_LANG_POP()
|
||||||
|
])
|
BIN
ng/Togl2.1/ben.rgb
Normal file
BIN
ng/Togl2.1/ben.rgb
Normal file
Binary file not shown.
10187
ng/Togl2.1/configure
vendored
Executable file
10187
ng/Togl2.1/configure
vendored
Executable file
File diff suppressed because it is too large
Load Diff
281
ng/Togl2.1/configure.in
Executable file
281
ng/Togl2.1/configure.in
Executable file
@ -0,0 +1,281 @@
|
|||||||
|
#!/bin/bash -norc
|
||||||
|
dnl This file is an input file used by the GNU "autoconf" program to
|
||||||
|
dnl generate the file "configure", which is run during Tcl installation
|
||||||
|
dnl to configure the system for the local environment.
|
||||||
|
#
|
||||||
|
# RCS: @(#) $Id: configure.in,v 1.17 2009/03/03 21:49:56 gregcouch Exp $
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Sample configure.in for Tcl Extensions. The only places you should
|
||||||
|
# need to modify this file are marked by the string __CHANGE__
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# __CHANGE__
|
||||||
|
# Set your package name and version numbers here.
|
||||||
|
#
|
||||||
|
# This initializes the environment with PACKAGE_NAME and PACKAGE_VERSION
|
||||||
|
# set as provided. These will also be added as -D defs in your Makefile
|
||||||
|
# so you can encode the package version directly into the source files.
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
AC_INIT([Togl], [2.1])
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# Call TEA_INIT as the first TEA_ macro to set up initial vars.
|
||||||
|
# This will define a ${TEA_PLATFORM} variable == "unix" or "windows"
|
||||||
|
# as well as PKG_LIB_FILE and PKG_STUB_LIB_FILE.
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
TEA_INIT([3.7])
|
||||||
|
|
||||||
|
AC_CONFIG_AUX_DIR(tclconfig)
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# Load the tclConfig.sh file
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
TEA_PATH_TCLCONFIG
|
||||||
|
TEA_LOAD_TCLCONFIG
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# Load the tkConfig.sh file if necessary (Tk extension)
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
TEA_PATH_TKCONFIG
|
||||||
|
TEA_LOAD_TKCONFIG
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Handle the --prefix=... option by defaulting to what Tcl gave.
|
||||||
|
# Must be called after TEA_LOAD_TCLCONFIG and before TEA_SETUP_COMPILER.
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
TEA_PREFIX
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Standard compiler checks.
|
||||||
|
# This sets up CC by using the CC env var, or looks for gcc otherwise.
|
||||||
|
# This also calls AC_PROG_CC, AC_PROG_INSTALL and a few others to create
|
||||||
|
# the basic setup necessary to compile executables.
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
TEA_SETUP_COMPILER
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# __CHANGE__
|
||||||
|
# Specify the C source files to compile in TEA_ADD_SOURCES,
|
||||||
|
# public headers that need to be installed in TEA_ADD_HEADERS,
|
||||||
|
# stub library C source files to compile in TEA_ADD_STUB_SOURCES,
|
||||||
|
# and runtime Tcl library files in TEA_ADD_TCL_SOURCES.
|
||||||
|
# This defines PKG(_STUB)_SOURCES, PKG(_STUB)_OBJECTS, PKG_HEADERS
|
||||||
|
# and PKG_TCL_SOURCES.
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
TOGL_ENABLE_STUBS
|
||||||
|
|
||||||
|
TEA_ADD_SOURCES([togl.c toglProcAddr.c toglStubInit.c])
|
||||||
|
# togl_ws.h is added in Makefile.in because it is generated
|
||||||
|
TEA_ADD_HEADERS([togl.h toglDecls.h])
|
||||||
|
TEA_ADD_INCLUDES([])
|
||||||
|
TEA_ADD_LIBS([])
|
||||||
|
TEA_ADD_CFLAGS([])
|
||||||
|
if test "${USE_STUBS}" = "1" ; then
|
||||||
|
TEA_ADD_STUB_SOURCES([toglStubLib.c])
|
||||||
|
fi
|
||||||
|
TEA_ADD_TCL_SOURCES([])
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# __CHANGE__
|
||||||
|
# A few miscellaneous platform-specific items:
|
||||||
|
#
|
||||||
|
# Define a special symbol for Windows (BUILD_sample in this case) so
|
||||||
|
# that we create the export library with the dll.
|
||||||
|
#
|
||||||
|
# Windows creates a few extra files that need to be cleaned up.
|
||||||
|
# You can add more files to clean if your extension creates any extra
|
||||||
|
# files.
|
||||||
|
#
|
||||||
|
# TEA_ADD_* any platform specific compiler/build info here.
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Add pkgIndex.tcl if it is generated in the Makefile instead of ./configure
|
||||||
|
# and change Makefile.in to move it from CONFIG_CLEAN_FILES to BINARIES var.
|
||||||
|
#CLEANFILES="pkgIndex.tcl"
|
||||||
|
if test "${TEA_PLATFORM}" = "windows" ; then
|
||||||
|
AC_DEFINE(BUILD_togl, 1, [Build windows export dll])
|
||||||
|
CLEANFILES="$CLEANFILES *.lib *.dll *.exp *.ilk *.pdb vc*.pch *.manifest"
|
||||||
|
#TEA_ADD_SOURCES([win/winFile.c])
|
||||||
|
#TEA_ADD_INCLUDES([-I\"$(${CYGPATH} ${srcdir}/win)\"])
|
||||||
|
else
|
||||||
|
# Ensure no empty else clauses
|
||||||
|
:
|
||||||
|
CLEANFILES="so_locations"
|
||||||
|
#TEA_ADD_SOURCES([unix/unixFile.c])
|
||||||
|
#TEA_ADD_LIBS([-lsuperfly])
|
||||||
|
fi
|
||||||
|
AC_SUBST(CLEANFILES)
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# __CHANGE__
|
||||||
|
# Choose which headers you need. Extension authors should try very
|
||||||
|
# hard to only rely on the Tcl public header files. Internal headers
|
||||||
|
# contain private data structures and are subject to change without
|
||||||
|
# notice.
|
||||||
|
# This MUST be called after TEA_LOAD_TCLCONFIG / TEA_LOAD_TKCONFIG
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
# find Tcl, Tk, and X11 headers
|
||||||
|
#TEA_PUBLIC_TCL_HEADERS
|
||||||
|
TEA_PRIVATE_TCL_HEADERS
|
||||||
|
|
||||||
|
#TEA_PUBLIC_TK_HEADERS
|
||||||
|
TEA_PRIVATE_TK_HEADERS
|
||||||
|
TEA_PATH_X
|
||||||
|
|
||||||
|
# find autostereo header, lib, and daemon
|
||||||
|
AC_ARG_WITH([autostereo],
|
||||||
|
[AS_HELP_STRING([--with-autostereo],
|
||||||
|
[directory with autostereo source (for SGI)])],
|
||||||
|
[with_autostereo=${withval}])
|
||||||
|
AC_ARG_WITH([autostereod],
|
||||||
|
[AS_HELP_STRING([--with-autostereod],
|
||||||
|
[path to autostereod daemon (for SGI)])],
|
||||||
|
[with_autostereod=${withval}])
|
||||||
|
AC_ARG_VAR([AUTOSTEREOD], [Path to autostereod for SGI IRIX computers])
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([for autostereo directory])
|
||||||
|
if test x"${with_autostereo}" != x ; then
|
||||||
|
if test -f "${with_autostereo}/lib/autostereo.h" ; then
|
||||||
|
with_autostereo=`(cd ${with_autostereo}; pwd)`
|
||||||
|
TEA_ADD_INCLUDES([-I${with_autostereo}/lib])
|
||||||
|
TEA_ADD_LIBS([-L${with_autostereo}/lib -lautostereo])
|
||||||
|
AC_DEFINE_UNQUOTED(HAVE_AUTOSTEREO, 1,
|
||||||
|
[Define this if you have the autostereo header])
|
||||||
|
else
|
||||||
|
AC_MSG_ERROR([${with_autostereo} directory doesn't contain lib/autostereo.h])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_PATH_PROG([AUTOSTEREOD], [autostereod], [],
|
||||||
|
[`eval \"echo $sbindir\"`:$PATH:/sbin:/usr/sbin])
|
||||||
|
|
||||||
|
|
||||||
|
# Choose OpenGL platform
|
||||||
|
case "${TEA_WINDOWINGSYSTEM}" in
|
||||||
|
aqua)
|
||||||
|
AC_SUBST(TOGL_WINDOWINGSYSTEM,TOGL_AGL)
|
||||||
|
TEA_ADD_LIBS([-framework AGL -framework OpenGL -framework ApplicationServices])
|
||||||
|
# libGLU is implicit in OpenGL framework
|
||||||
|
LIBGLU=
|
||||||
|
;;
|
||||||
|
x11)
|
||||||
|
AC_SUBST(TOGL_WINDOWINGSYSTEM,TOGL_X11)
|
||||||
|
AC_ARG_WITH([Xmu],
|
||||||
|
[AS_HELP_STRING([--with-Xmu],
|
||||||
|
[use system's shared Xmu library])],
|
||||||
|
[],
|
||||||
|
[with_Xmu=no])
|
||||||
|
AS_IF([test "x$with_Xmu" != xno],
|
||||||
|
[AC_CHECK_LIB([Xmu], [XmuLookupStandardColormap],
|
||||||
|
[TEA_ADD_LIBS([-lXmu])
|
||||||
|
AC_DEFINE(USE_SYSTEM_LIBXMU, 1,
|
||||||
|
[Define to use system Xmu library])
|
||||||
|
],
|
||||||
|
[with_Xmu=no],
|
||||||
|
[-lXt -lX11]
|
||||||
|
)])
|
||||||
|
AS_IF([test "x$with_Xmu" = xno],
|
||||||
|
[TEA_ADD_SOURCES([Xmu/CmapAlloc.c Xmu/CrCmap.c Xmu/DelCmap.c Xmu/LookupCmap.c Xmu/StdCmap.c])])
|
||||||
|
TEA_ADD_LIBS([-lGL])
|
||||||
|
LIBGLU=-lGLU
|
||||||
|
TOGL_UNDEF_GET_PROC_ADDRESS
|
||||||
|
;;
|
||||||
|
win32)
|
||||||
|
AC_SUBST(TOGL_WINDOWINGSYSTEM,TOGL_WGL)
|
||||||
|
TEA_ADD_LIBS([opengl32.lib user32.lib gdi32.lib])
|
||||||
|
if test "$GCC" = "yes" ; then
|
||||||
|
LIBGLU=-lglu32
|
||||||
|
else
|
||||||
|
# assume Microsoft compiler
|
||||||
|
LIBGLU=glu32.lib
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
AC_MSG_ERROR([Unsupported windowing system: ${TEA_WINDOWINGSYSTEM}])
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
AC_SUBST(LIBGLU)
|
||||||
|
AC_SUBST(TEA_WINDOWINGSYSTEM)
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# Check whether --enable-threads or --disable-threads was given.
|
||||||
|
# This auto-enables if Tcl was compiled threaded.
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
TEA_ENABLE_THREADS
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# The statement below defines a collection of symbols related to
|
||||||
|
# building as a shared library instead of a static library.
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
TEA_ENABLE_SHARED
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# This macro figures out what flags to use with the compiler/linker
|
||||||
|
# when building shared/static debug/optimized objects. This information
|
||||||
|
# can be taken from the tclConfig.sh file, but this figures it all out.
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
TEA_CONFIG_CFLAGS
|
||||||
|
# should be part of TEA_CONFIG_CFLAGS, but more visible modification here
|
||||||
|
AC_SUBST(SHLIB_SUFFIX)
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# Set the default compiler switches based on the --enable-symbols option.
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
TEA_ENABLE_SYMBOLS
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# Everyone should be linking against the Tcl stub library. If you
|
||||||
|
# can't for some reason, remove this definition. If you aren't using
|
||||||
|
# stubs, you also need to modify the SHLIB_LD_LIBS setting below to
|
||||||
|
# link against the non-stubbed Tcl library. Add Tk too if necessary.
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
if test "${USE_STUBS}" = "1" ; then
|
||||||
|
AC_DEFINE(USE_TCL_STUBS, 1, [Use Tcl stubs])
|
||||||
|
AC_DEFINE(USE_TK_STUBS, 1, [Use Tk stubs])
|
||||||
|
fi
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# This macro generates a line to use when building a library. It
|
||||||
|
# depends on values set by the TEA_ENABLE_SHARED, TEA_ENABLE_SYMBOLS,
|
||||||
|
# and TEA_LOAD_TCLCONFIG macros above.
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
TEA_MAKE_LIB
|
||||||
|
|
||||||
|
if test "${USE_STUBS}" = "0" ; then
|
||||||
|
SHLIB_LD_LIBS=`echo "$SHLIB_LD_LIBS" | sed -e 's!stub!!g'`
|
||||||
|
fi
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# Determine the name of the tclsh and/or wish executables in the
|
||||||
|
# Tcl and Tk build directories or the location they were installed
|
||||||
|
# into. These paths are used to support running test cases only,
|
||||||
|
# the Makefile should not be making use of these paths to generate
|
||||||
|
# a pkgIndex.tcl file or anything else at extension build time.
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
TEA_PROG_TCLSH
|
||||||
|
#TEA_PROG_WISH
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# Finally, substitute all of the various values into the Makefile.
|
||||||
|
# You may alternatively have a special pkgIndex.tcl.in or other files
|
||||||
|
# which require substituting th AC variables in. Include these here.
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
AC_OUTPUT([Makefile pkgIndex.tcl togl_ws.h])
|
2
ng/Togl2.1/doc/README.txt
Normal file
2
ng/Togl2.1/doc/README.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
This directory contains the documentation of Togl, the Tk OpenGL widget.
|
||||||
|
The documentation also doubles as the contents of the Togl home page.
|
652
ng/Togl2.1/doc/capi.html
Normal file
652
ng/Togl2.1/doc/capi.html
Normal file
@ -0,0 +1,652 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<!-- vi:set sw=2: -->
|
||||||
|
<!--
|
||||||
|
Copyright (C) 1996-2002 Brian Paul and Ben Bederson
|
||||||
|
Copyright (C) 2005-2009 Greg Couch
|
||||||
|
See the LICENSE file for copyright details.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||||
|
<title>Togl C API</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<script type="text/javascript" src="header.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
NavigationBar();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h1 align="center">Togl C API</h1>
|
||||||
|
|
||||||
|
<h2>Contents</h2>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#compile">Compiling and linking C Togl Functions</a>
|
||||||
|
<li><a href="#setup">Setup and Initialization Functions</a>
|
||||||
|
<ul>
|
||||||
|
<li><code>Togl_Init</code>,
|
||||||
|
<code>Togl_InitStubs</code>
|
||||||
|
</ul>
|
||||||
|
<li><a href="#drawing">Drawing-related Commands</a>
|
||||||
|
<ul>
|
||||||
|
<li><code>Togl_PostRedisplay</code>,
|
||||||
|
<code>Togl_SwapBuffers</code>,
|
||||||
|
<code>Togl_MakeCurrent</code>,
|
||||||
|
<code>Togl_SwapInterval</code>
|
||||||
|
<code>Togl_CopyContext</code>
|
||||||
|
</ul>
|
||||||
|
<li><a href="#query">Query Functions</a>
|
||||||
|
<ul>
|
||||||
|
<li><code>Togl_Ident</code>,
|
||||||
|
<code>Togl_Width</code>,
|
||||||
|
<code>Togl_Height</code>,
|
||||||
|
<code>Togl_Interp</code>,
|
||||||
|
<code>Togl_TkWin</code>,
|
||||||
|
<code>Togl_GetProcAddr</code>,
|
||||||
|
<code>Togl_ContextTag</code>
|
||||||
|
<code>Togl_UpdatePending</code>
|
||||||
|
<code>Togl_HasRGBA</code>
|
||||||
|
<code>Togl_IsDoubleBuffered</code>
|
||||||
|
<code>Togl_HasDepthBuffer</code>
|
||||||
|
<code>Togl_HasAccumulationBuffer</code>
|
||||||
|
<code>Togl_HasDestinationAlpha</code>
|
||||||
|
<code>Togl_HasStencilBuffer</code>
|
||||||
|
<code>Togl_StereoMode</code>
|
||||||
|
<code>Togl_HasMultisample</code>
|
||||||
|
</ul>
|
||||||
|
<li><a href="#index">Color Index Mode Functions</a>
|
||||||
|
<ul>
|
||||||
|
<li><code>Togl_AllocColor</code>,
|
||||||
|
<code>Togl_FreeColor</code>,
|
||||||
|
<code>Togl_SetColor</code>
|
||||||
|
</ul>
|
||||||
|
<li><a href="#font">Font Functions</a>
|
||||||
|
<ul>
|
||||||
|
<li><code>Togl_LoadBitmapFont</code>,
|
||||||
|
<code>Togl_UnloadBitmapFont</code>,
|
||||||
|
<code>Togl_WriteObj</code>,
|
||||||
|
<code>Togl_WriteChars</code>
|
||||||
|
</ul>
|
||||||
|
<li><a href="#client">Client Data Functions</a>
|
||||||
|
<ul>
|
||||||
|
<li><code>Togl_SetClientData</code>,
|
||||||
|
<code>Togl_GetClientData</code>
|
||||||
|
</ul>
|
||||||
|
<li><a href="#overlay">Overlay Functions</a>
|
||||||
|
<ul>
|
||||||
|
<li><code>Togl_UseLayer</code>,
|
||||||
|
<code>Togl_ShowOverlay</code>,
|
||||||
|
<code>Togl_HideOverlay</code>,
|
||||||
|
<code>Togl_PostOveralyRedisplay</code>,
|
||||||
|
<code>Togl_ExistsOverlay</code>,
|
||||||
|
<code>Togl_GetOverlayTransparentValue</code>,
|
||||||
|
<code>Togl_IsMappedOverlay</code>,
|
||||||
|
<code>Togl_AllocColorOverlay</code>,
|
||||||
|
<code>Togl_FreeColorOverlay</code>
|
||||||
|
</ul>
|
||||||
|
<li><a href="#stereo">Stereo Functions</a>
|
||||||
|
<ul>
|
||||||
|
<li><code>Togl_Drawbuffer</code>,
|
||||||
|
<li><code>Togl_Clear</code>
|
||||||
|
<li><code>Togl_Frustum</code>
|
||||||
|
<li><code>Togl_Ortho</code>
|
||||||
|
<li><code>Togl_NumEyes</code>
|
||||||
|
</ul>
|
||||||
|
<li><a href="#image">Image Functions</a>
|
||||||
|
<ul>
|
||||||
|
<li><code>Togl_TakePhoto</code>
|
||||||
|
</ul>
|
||||||
|
<li><a href="#convert">Conversion Functions</a>
|
||||||
|
<ul>
|
||||||
|
<li><code>Togl_GetToglFromObj</code>,
|
||||||
|
<li><code>Togl_GetToglFromName</code>
|
||||||
|
</ul>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<h2><a name="compile">Compiling and linking C Togl Functions</a></h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
All Togl functions are found in the Togl header file.
|
||||||
|
|
||||||
|
<blockquote>
|
||||||
|
<code>
|
||||||
|
#include "togl.h"
|
||||||
|
</code>
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
For portability, you should include the <code>togl.h</code> header
|
||||||
|
before any other OpenGL headers
|
||||||
|
so it will compile on Microsoft Windows.
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Before calling any Togl functions, you need to initialize it.
|
||||||
|
Regardless if you're using stubs (by defining <code>USE_TOGL_STUBS</code>)
|
||||||
|
or not, the following code will properly initialize togl:
|
||||||
|
|
||||||
|
<blockquote><pre>
|
||||||
|
if (Tcl_InitStubs(interp, "8.1", 0) == NULL
|
||||||
|
|| Togl_InitStubs(interp, "2.0", 0) == NULL) {
|
||||||
|
/* fail */
|
||||||
|
}
|
||||||
|
</pre></blockquote>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
If you are using a prebuilt binary distribution,
|
||||||
|
you should be sure to define <code>USE_TOGL_STUBS</code> beforehand.
|
||||||
|
|
||||||
|
<p>
|
||||||
|
See the source for the demo programs in the Togl source distribution
|
||||||
|
for working examples.
|
||||||
|
|
||||||
|
<h3>Linking</h3>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
If you are using a prebuilt binary,
|
||||||
|
be sure to link against the stub library.
|
||||||
|
On Microsoft Windows,
|
||||||
|
link against <code>Toglstub21.lib opengl32.lib user32.lib gdi32.lib</code>,
|
||||||
|
on Mac OS X,
|
||||||
|
link against <code>-lToglstub2.1 -framework OpenGL</code>,
|
||||||
|
on other platforms,
|
||||||
|
link against <code>-lToglstub2.1 -lGLU -lGL -lm</code>.
|
||||||
|
|
||||||
|
<p>
|
||||||
|
If building your own Togl package,
|
||||||
|
you can use the stubs interface or link in the Tcl and Tk libraries as well.
|
||||||
|
If using the stubs interface, link as shown above.
|
||||||
|
Otherwise:
|
||||||
|
on Microsoft Windows,
|
||||||
|
link against <code>Togl21.lib tk84.lib tcl84.lib opengl32.lib user32.lib gdi32.lib</code>,
|
||||||
|
on Mac OS X,
|
||||||
|
link against <code>-lTogl2.1 -framework Tk -framework Tcl -framework OpenGL</code>,
|
||||||
|
on other platforms,
|
||||||
|
link against <code>-lTogl2.1 -ltk8.4 -ltcl8.4 -lGLU -lGL -lm</code>.
|
||||||
|
|
||||||
|
<h2><a name="setup">Setup and Initialization Functions</a></h2>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>int Togl_Init(Tcl_Interp *interp)</code>
|
||||||
|
<dd>
|
||||||
|
Initializes the Togl module. This is typically called from the
|
||||||
|
Tk_Main() function
|
||||||
|
or other Tcl package initialization function that is directly linked
|
||||||
|
to the Togl (shared) library.
|
||||||
|
It is also indirectly called via
|
||||||
|
Tcl's <code>package require Togl</code> command.
|
||||||
|
If successful, the return value is TCL_OK.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt>
|
||||||
|
<code>const char *Togl_InitStubs(Tcl_Interp *interp, const char *version, int exact)</code>
|
||||||
|
<dd>
|
||||||
|
Loads the Togl package into the given <code>interp</code>reter
|
||||||
|
and initializes it.
|
||||||
|
<code>version</code> should be <code>"2.0"</code> or higher.
|
||||||
|
This is typically called from C/C++ code that accesses Togl's C API
|
||||||
|
and has installed Togl into the standard TCL hierarchy.
|
||||||
|
See the Tcl InitStubs(3) or the Tk TkInitStubs(3) manual pages for
|
||||||
|
more information.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<h2><a name="drawing">Drawing-related Commands</a></h2>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>void Togl_PostRedisplay(Togl *togl)</code>
|
||||||
|
<dd>
|
||||||
|
Signals that the widget should be redrawn. When Tk is next idle,
|
||||||
|
the <code>displaycommand</code> callback will be invoked.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>void Togl_SwapBuffers(const Togl *togl)</code>
|
||||||
|
<dd>
|
||||||
|
Swaps the front and back color buffers for a double-buffered widget.
|
||||||
|
<a href="http://www.opengl.org/sdk/docs/man/xhtml/glFlush.xml">
|
||||||
|
glFlush</a> is executed if the window is single-buffered. So this call
|
||||||
|
works for both single- and double-buffered contexts. This is
|
||||||
|
typically called in the <code>displaycommand</code> callback function.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>void Togl_MakeCurrent(const Togl *togl)</code>
|
||||||
|
<dd>
|
||||||
|
Sets the current rendering context to the given widget. This is done
|
||||||
|
automatically before any Togl callback functions is called. So the
|
||||||
|
call is only needed if you have multiple widgets with separate OpenGL
|
||||||
|
contexts. If the argument is NULL, then the rendering context is cleared
|
||||||
|
and subsequent OpenGL commands will fail.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>Bool Togl_SwapInterval(const Togl *togl, int interval)</code>
|
||||||
|
<dd>
|
||||||
|
Returns True if successful.
|
||||||
|
Attempts to change the maximum refresh rate
|
||||||
|
by setting the minimum number of cycles between successive swap buffers.
|
||||||
|
For benchmarking purposes, you should set the swap interval to 0.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>int Togl_CopyContext(const Togl *from, const Togl *to, unsigned int mask)</code>
|
||||||
|
<dd>
|
||||||
|
Copy a subset of the OpenGL context state from from one context
|
||||||
|
to another using the mask parameter who values are the same as
|
||||||
|
<a href="http://www.opengl.org/sdk/docs/man/xhtml/glPushAttrib.xml">
|
||||||
|
glPushAttrib</a>.
|
||||||
|
The return value is TCL_OK if the context was copied.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<h2><a name="query">Query Functions</a></h2>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>char *Togl_Ident(const Togl *togl)</code>
|
||||||
|
<dd>
|
||||||
|
Returns a pointer to the identification string associated with a Togl
|
||||||
|
widget or NULL if there's no identifier string.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>int Togl_Width(const Togl *togl)</code>
|
||||||
|
<dd>
|
||||||
|
Returns the width of the given Togl widget. Typically called in the
|
||||||
|
<code>reshapecommand</code> callback function.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>int Togl_Height(const Togl *togl)</code>
|
||||||
|
<dd>
|
||||||
|
Returns the height of the given Togl widget. Typically called in the
|
||||||
|
<code>reshapecommand</code> callback function.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>Tcl_Interp *Togl_Interp(const Togl *togl)</code>
|
||||||
|
<dd>
|
||||||
|
Returns the Tcl interpreter associated with the given Togl widget.
|
||||||
|
</dl>
|
||||||
|
<dl>
|
||||||
|
<dt>
|
||||||
|
<code>Tk_Window Togl_TkWin(const Togl *togl)</code>
|
||||||
|
<dd>
|
||||||
|
Returns the Tk window associated with the given Togl widget.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>Togl_FuncPtr Togl_GetProcAddr(const char *funcname)</code>
|
||||||
|
<dd>
|
||||||
|
Platform-independent way to get OpenGL function pointers from a
|
||||||
|
function name.
|
||||||
|
Note that in Microsoft Windows (WGL) versions that
|
||||||
|
"the extension function addresses are unique for each pixel format.
|
||||||
|
All rendering contexts of a given pixel format
|
||||||
|
share the same extension function addresses."
|
||||||
|
And on *nix (GLX/X11) platforms,
|
||||||
|
"the function pointers returned are context independent"
|
||||||
|
(Linux ABI documentation).
|
||||||
|
The Mac OS X (AGL) platform acts like a *nix platform.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>int Togl_ContextTag(const Togl *t)</code>
|
||||||
|
<dd>
|
||||||
|
Returns an integer that represents the context tag.
|
||||||
|
All Togl widgets with the same context tag share display lists.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>Bool Togl_UpdatePending(const Togl *t)</code>
|
||||||
|
<dd>
|
||||||
|
Returns True if the window should be redrawn. See Togl_PostRedisplay.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>Bool Togl_HasRGBA(const Togl *t)</code>
|
||||||
|
<dd>
|
||||||
|
Return True if Togl widget has a RBGA color buffer.
|
||||||
|
False means that the widget is using a color index buffer.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>Bool Togl_IsDoubleBuffered(const Togl *t)</code>
|
||||||
|
<dd>
|
||||||
|
Return True if Togl widget is double buffered.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>Bool Togl_HasDepthBuffer(const Togl *t)</code>
|
||||||
|
<dd>
|
||||||
|
Return True if Togl widget is has a depth buffer.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>Bool Togl_HasAccumulationBuffer(const Togl *t)</code>
|
||||||
|
<dd>
|
||||||
|
Return True if Togl widget has an accumulation buffer.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>Bool Togl_HasDestinationAlpha(const Togl *t)</code>
|
||||||
|
<dd>
|
||||||
|
Return True if Togl widget has a destination alpha buffer.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>Bool Togl_HasStencilBuffer(const Togl *t)</code>
|
||||||
|
<dd>
|
||||||
|
Return True if Togl widget has a stencil buffer.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>int Togl_StereoMode(const Togl *t)</code>
|
||||||
|
<dd>
|
||||||
|
Return current stereo mode. See ??
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>Bool Togl_HasMultisample(const Togl *t)</code>
|
||||||
|
<dd>
|
||||||
|
Return True if Togl widget has a multisample buffer.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<h2><a name="index">Color Index Mode Functions</a></h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
These functions are only used for color index mode.
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>unsigned long Togl_AllocColor(Togl *togl, float red, float green, float blue)</code>
|
||||||
|
<dd>
|
||||||
|
Allocate a color from a read-only colormap. Given a color specified
|
||||||
|
by red, green, and blue return a colormap index (aka pixel value)
|
||||||
|
whose entry most closely matches the red, green, blue color. Red,
|
||||||
|
green, and blue are values in [0,1]. This function is only used in
|
||||||
|
color index mode when the <code>-privatecmap</code> option is false.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>void Togl_FreeColor(Togl *togl, unsigned long index)</code>
|
||||||
|
<dd>
|
||||||
|
Free a color in a read-only colormap. Index is a value which was
|
||||||
|
returned by the Togl_AllocColor() function. This function is only
|
||||||
|
used in color index mode when the <code>-privatecmap</code> option
|
||||||
|
is false.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>void Togl_SetColor(Togl *togl,
|
||||||
|
int index, float red, float green, float blue)</code>
|
||||||
|
<dd>
|
||||||
|
Load the colormap entry specified by index with the given red, green
|
||||||
|
and blue values. Red, green, and blue are values in [0,1]. This
|
||||||
|
function is only used in color index mode when the
|
||||||
|
<code>-privatecmap</code> option is true.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a name="font">Font Functions</a></h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
These functions provide an interface to the simple bitmap font capabilities
|
||||||
|
that every OpenGL implementation provides.
|
||||||
|
Better font support is found in other C APIs, <i>e.g.</i>,
|
||||||
|
<a href="http://quesoglc.sourceforge.net/">QuesoGLC</a>
|
||||||
|
or <a href="http://sourceforge.net/projects/ftgl">FTGL</a>.
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>Tcl_Obj *Togl_LoadBitmapFont(Togl *togl,
|
||||||
|
const char *fontname)</code>
|
||||||
|
<dd>
|
||||||
|
Load the named font as a set of
|
||||||
|
<a href="http://www.opengl.org/sdk/docs/man/xhtml/glBitmap.xml">
|
||||||
|
glBitmap</a> display lists.
|
||||||
|
<var>fontname</var> may be any of the font description styles
|
||||||
|
accepted by the Tk font command.
|
||||||
|
For maximum portability, one of the standard Tk fonts,
|
||||||
|
<b>Courier</b>, <b>Times</b>, and <b>Helvetica</b>, should be used.
|
||||||
|
Unicode fonts are treated as if they have only have an 8-bit index
|
||||||
|
(so poorly).
|
||||||
|
If successful, a Togl BitmapFont object is returned.
|
||||||
|
NULL is returned on failure.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>int Togl_UnloadBitmapFont(Togl *togl, Tcl_Obj *toglfont)
|
||||||
|
</code>
|
||||||
|
<dd>
|
||||||
|
Destroys the bitmap display lists created by by Togl_LoadBitmapFont().
|
||||||
|
If successful, the return value is TCL_OK.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>int Togl_WriteChars(const Togl *togl, const Tcl_Obj *toglfont, const char *string, int length)
|
||||||
|
</code>
|
||||||
|
Draw the given <em>string</em>.
|
||||||
|
If the given <em>length</em> is zero, then it is computed using strlen.
|
||||||
|
Returns the length of the drawn string.
|
||||||
|
<dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>int Togl_WriteObj(const Togl *togl, const Tcl_Obj *toglfont, Tcl_Obj *obj)
|
||||||
|
</code>
|
||||||
|
<dd>
|
||||||
|
Tcl_Obj interface to <code>Tcl_WriteChars</code>.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<h2><a name="client">Client Data Functions</a></h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Each Togl structure has a pointer to an arbitrary client data structure.
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>void Togl_SetClientData(Togl *togl, ClientData clientData)</code>
|
||||||
|
<dd>
|
||||||
|
Set the Togl widget's client data pointer to <em>clientData</em>.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>ClientData Togl_GetClientData(const Togl *togl)</code>
|
||||||
|
<dd>
|
||||||
|
Return the Togl widget's client data pointer.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a name="overlay">Overlay Functions</a></h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
These functions are modeled after GLUT's overlay sub-API.
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>void Togl_UseLayer(Togl *togl, int layer)</code>
|
||||||
|
<dd>
|
||||||
|
Select the layer into which subsequent OpenGL rendering will be
|
||||||
|
directed. <em>layer</em> may be either <em>TOGL_OVERLAY</em> or
|
||||||
|
<em>TOGL_NORMAL</em>.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>void Togl_ShowOverlay(Togl *togl)</code>
|
||||||
|
<dd>
|
||||||
|
Display the overlay planes, if any.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>void Togl_HideOverlay(Togl *togl)</code>
|
||||||
|
<dd>
|
||||||
|
Hide the overlay planes, if any.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>void Togl_PostOverlayRedisplay(Togl *togl)</code>
|
||||||
|
<dd>
|
||||||
|
Signal that the overlay planes should be redraw.
|
||||||
|
When Tk is next idle,
|
||||||
|
the <code>overlaydisplaycommand</code> callback will be invoked.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>int Togl_ExistsOverlay(Togl *togl)</code>
|
||||||
|
<dd>
|
||||||
|
Returns 1 if overlay planes exist, 0 otherwise.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>int Togl_GetOverlayTransparentValue(const Togl *togl)</code>
|
||||||
|
<dd>
|
||||||
|
Returns the color index of the overlay's transparent pixel value.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>int Togl_IsMappedOverlay(const Togl *togl)</code>
|
||||||
|
<dd>
|
||||||
|
Returns 1 if the overlay planes are currently displayed, 0 otherwise.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>unsigned long Togl_AllocColorOverlay(const Togl *togl,
|
||||||
|
float red, float green, float blue)</code>
|
||||||
|
<dd>
|
||||||
|
Allocate a color in the overlay planes. Red, green, and blue are
|
||||||
|
values in [0,1]. Return the color index or -1 if the allocation
|
||||||
|
fails.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>void Togl_FreeColorOverlay(const Togl *togl, unsigned long index)</code>
|
||||||
|
<dd>
|
||||||
|
Free a color which was allocated with Togl_AllocColorOverlay().
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<h2><a name="stereo">Stereo Functions</a></h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Togl abstracts part of the stereo drawing process to seamlessly
|
||||||
|
support quad-buffered stereo as well as various alternative stereo
|
||||||
|
formats. The stereo viewing parameters, <code>eyeseparation</code>
|
||||||
|
and <code>convergence</code> need to be set with the Togl's
|
||||||
|
<a href="tclapi.html#stereo options">stereo options</a>.
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>void Togl_DrawBuffer(Togl *togl, GLenum mode)</code>
|
||||||
|
<dd>
|
||||||
|
Switch to OpenGL draw buffer.
|
||||||
|
Should be one of GL_BACK_LEFT, GL_BACK_RIGHT, GL_FRONT_LEFT, or
|
||||||
|
GL_FRONT_RIGHT.
|
||||||
|
It is not possible to draw in the left and right buffers at the same
|
||||||
|
time in the alternate stereo modes.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>void Togl_Clear(const Togl *togl, GLbitfield mask)</code>
|
||||||
|
<dd>
|
||||||
|
Replacement for OpenGL's
|
||||||
|
<a href="http://www.opengl.org/sdk/docs/man/xhtml/glClear.xml">
|
||||||
|
glClear</a> that takes into account the alternate stereo mode.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>void Togl_Frustum(const Togl *togl, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat near, GLfloat far)</code>
|
||||||
|
<dd>
|
||||||
|
Replacement for OpenGL's
|
||||||
|
<a href="http://www.opengl.org/sdk/docs/man/xhtml/glFrustum.xml">
|
||||||
|
glFrustum</a> that takes into account the alternate stereo mode.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>void Togl_Ortho(const Togl *togl, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat near, GLfloat far)</code>
|
||||||
|
<dd>
|
||||||
|
Replacement for OpenGL's
|
||||||
|
<a href="http://www.opengl.org/sdk/docs/man/xhtml/glOrtho.xml">
|
||||||
|
glOrtho</a> that takes into account the alternate stereo mode.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>int Togl_NumEyes(const Togl *togl)</code>
|
||||||
|
<dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<h3>Stereo Example</h3>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
This code works for quad-buffered stereo,
|
||||||
|
as well as the other stereo modes.
|
||||||
|
|
||||||
|
<blockquote><pre>
|
||||||
|
if (Togl_NumEyes(togl) == 1) {
|
||||||
|
Togl_DrawBuffer(togl, GL_BACK);
|
||||||
|
Togl_Clear(togl);
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
Togl_Frustum(togl, left, right, bottom, top, near, far);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
<b><i>draw image</i></b>
|
||||||
|
} else {
|
||||||
|
Togl_DrawBuffer(togl, GL_BACK_LEFT);
|
||||||
|
Togl_Clear(togl);
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
Togl_Frustum(togl, left, right, bottom, top, near, far);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
<b><i>draw left-eye image</i></b>
|
||||||
|
Togl_DrawBuffer(togl, GL_BACK_RIGHT);
|
||||||
|
Togl_Clear(togl);
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
Togl_Frustum(togl, left, right, bottom, top, near, far);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
<b><i>draw right-eye image</i></b>
|
||||||
|
}
|
||||||
|
Togl_SwapBuffers(togl);
|
||||||
|
</pre></blockquote>
|
||||||
|
|
||||||
|
<h2><a name="image">Image Functions</a></h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<!--description-->
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>int Togl_TakePhoto(Togl *togl, Tk_PhotoHandle photo)</code>
|
||||||
|
<dd>
|
||||||
|
Take a photo image of the current Togl window and place it in the
|
||||||
|
given <code>photo</code> object.
|
||||||
|
If the window is partially obscured,
|
||||||
|
either by other windows or by the edges of the display,
|
||||||
|
the results are undefined in the obscured region.
|
||||||
|
If successful, the return value is TCL_OK.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<h2><a name="convert">Conversion Functions</a></h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
These functions aid the programmer when writing Togl callback functions.
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>int Togl_GetToglFromObj(Tcl_Interp *interp, Tcl_Obj *obj, Togl **toglPtr)</code>
|
||||||
|
<dd>
|
||||||
|
Attempt to return a Togl structure "toglPtr" from the Tcl object "obj".
|
||||||
|
If successful, the return value is TCL_OK.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code>int Togl_GetToglFromName(Tcl_Interp *interp, const char *cmdName, Togl **toglPtr)</code>
|
||||||
|
<dd>
|
||||||
|
Attempt to return a Togl structure "toglPtr" from the Tcl command name "cmdName".
|
||||||
|
If successful, the return value is TCL_OK.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<a href="http://sourceforge.net/projects/togl">
|
||||||
|
<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=519&type=13" width="120" height="30" border="0" alt="Get Togl at SourceForge.net. Fast, secure and Free Open Source software downloads">
|
||||||
|
</a>
|
||||||
|
<a href="http://validator.w3.org/check?uri=referer">
|
||||||
|
<img src="http://www.w3.org/Icons/valid-html401-blue"
|
||||||
|
alt="Valid HTML 4.01 Transitional" height="31" width="88" border="0">
|
||||||
|
</a>
|
||||||
|
</body>
|
||||||
|
</html>
|
340
ng/Togl2.1/doc/download.html
Normal file
340
ng/Togl2.1/doc/download.html
Normal file
@ -0,0 +1,340 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<!-- vi:set sw=2: -->
|
||||||
|
<!--
|
||||||
|
Copyright (C) 1996-2002 Brian Paul and Ben Bederson
|
||||||
|
Copyright (C) 2005-2009 Greg Couch
|
||||||
|
See the LICENSE file for copyright details.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||||
|
<title>Downloading and Installing Togl</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<script type="text/javascript" src="header.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
NavigationBar();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h1 align="center">Downloading and Installing Togl</h1>
|
||||||
|
|
||||||
|
<h2>Contents</h2>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#prereq">Prerequisites</a>
|
||||||
|
<li><a href="#getting">Downloading</a>
|
||||||
|
<li><a href="#building">Installing</a>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#x11">X11 usage</a>
|
||||||
|
<li><a href="#windows">Microsoft Windows usage</a>
|
||||||
|
<li><a href="#macosx">Mac OS X usage</a>
|
||||||
|
</ul>
|
||||||
|
<li><a href="#version">Version History</a>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<h2><a name="prereq">Prerequisites</a></h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
You should have
|
||||||
|
<a href="http://www.tcl.tk/">Tcl and Tk</a>
|
||||||
|
installed on your computer.
|
||||||
|
Togl works with Tcl/Tk version 8.1 and up
|
||||||
|
(all recent testing has been with version 8.4).
|
||||||
|
The Mac OS X version requires version 8.4
|
||||||
|
(note: versions 8.4.12 and 8.4.13 have a bug when unmapping Togl widgets).
|
||||||
|
|
||||||
|
<p>
|
||||||
|
You must also have
|
||||||
|
<a href="http://www.opengl.org">OpenGL</a> or
|
||||||
|
<a href="http://www.mesa3d.org">Mesa</a>
|
||||||
|
(a free alternative to OpenGL with the same API)
|
||||||
|
installed on your computer.
|
||||||
|
|
||||||
|
<p>
|
||||||
|
And one should be familiar with Tcl, Tk, OpenGL,
|
||||||
|
and C programming to use Togl effectively.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<h2><a name="getting">Downloading Togl</a></h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Togl can be downloaded from the
|
||||||
|
<a href="http://sourceforge.net/project/showfiles.php?group_id=519">
|
||||||
|
SourceForge</a> Files page.
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Several prebuilt binary distributions are available
|
||||||
|
as well as a source distribution.
|
||||||
|
|
||||||
|
<h2><a name="building">Installing Togl</a></h2>
|
||||||
|
|
||||||
|
<h3>Installing prebuild binaries</h3>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Prebuilt binaries provide a Togl2.1 directory,
|
||||||
|
the togl.h, togl_ws.h and toglDecls.h include files,
|
||||||
|
and the togl stub library
|
||||||
|
(libToglstub2.1.a or Toglstub20.lib, <i>etc</i>).
|
||||||
|
The Togl2.1 directory needs to copied
|
||||||
|
into one of the directories on Tcl's package path
|
||||||
|
(type <code>puts $auto_path</code> in the Tcl interpreter to see
|
||||||
|
the list of directories).
|
||||||
|
If you have C code that needs to access Togl's subroutines directly,
|
||||||
|
place the include file in the same place as Tcl's include file and
|
||||||
|
the stub library in the same place as Tcl's stub library.
|
||||||
|
|
||||||
|
<h3>Installing from source</h3>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Togl uses the Tcl Extension Architecture to be able to build on the
|
||||||
|
same platforms Tcl can be built on.
|
||||||
|
In addition to the Togl source,
|
||||||
|
you will need to have the Tcl and Tk source distributions
|
||||||
|
because not all installations have the needed Tcl and Tk internal header files.
|
||||||
|
|
||||||
|
<p>
|
||||||
|
How you link with Togl depends on how you're planning to use it.
|
||||||
|
There are basically three ways of using Togl with your application:
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
Install the Togl shared library and pkgIndex.tcl file
|
||||||
|
(using <code>make install</code>)
|
||||||
|
and link to the Togl stubs library with your executable or shared library.
|
||||||
|
In this case you must call Togl_InitStubs() (and probably Tcl_InitStubs()
|
||||||
|
— Tk_InitStubs is only needed if you call Tk functions).
|
||||||
|
This is the way the included Togl examples are built.
|
||||||
|
|
||||||
|
<li>
|
||||||
|
Link to the Togl shared library
|
||||||
|
or "compile in" the Togl object files
|
||||||
|
with your executable or shared library.
|
||||||
|
In this case you must call Togl_Init() from your C code
|
||||||
|
to initialize Togl.
|
||||||
|
|
||||||
|
<li>
|
||||||
|
Install the Togl shared library and pkgIndex.tcl file
|
||||||
|
(using <code>make install</code>)
|
||||||
|
and then load it using Tcl commands or Tcl_PkgRequire().
|
||||||
|
Then use Tcl commands to create and manipulate the Togl widget.
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
Since Togl is compiled into a shared library using the Tcl/Tk stubs-interface,
|
||||||
|
the same binary can be used with any version of Tck/Tk from 8.1 and up.
|
||||||
|
See <code>README.stubs</code> for more info.
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Specific platform notes follow:
|
||||||
|
|
||||||
|
<h4><a name="x11">Unix/X11 usage</a></h4>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Unix/X systems only need the public Tcl/Tk include files.
|
||||||
|
Just <code>configure</code>, <code>make</code>,
|
||||||
|
and optionally <code>make install</code>.
|
||||||
|
|
||||||
|
<h4><a name="windows">Microsoft Windows usage</a></h4>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Microsoft Windows platforms need <code>tkWinInt.h</code>
|
||||||
|
and other internal Tk header files. So you need a Tcl/Tk
|
||||||
|
source distribution in addition to the Togl distribution
|
||||||
|
(or copy over the various include files).
|
||||||
|
<p>
|
||||||
|
Here's the minimal way to build Togl with Tcl/Tk
|
||||||
|
using the <a href="http://gcc.gnu.org">gcc</a> that is distributed
|
||||||
|
as part of the <a href="http://cygwin.com/">cygwin</a> tools
|
||||||
|
(<a href="www.microsoft.com">Microsoft</a>'s compilers work too):
|
||||||
|
<blockquote><pre><code>
|
||||||
|
VER=8.4.12
|
||||||
|
SRCDIR=`pwd`
|
||||||
|
|
||||||
|
cd $SRCDIR/tcl$VER/win
|
||||||
|
env 'CC=gcc -mno-cygwin' ./configure --enable-threads
|
||||||
|
make libtclstub84.a
|
||||||
|
|
||||||
|
cd $SRCDIR/tk$VER/win
|
||||||
|
env 'CC=gcc -mno-cygwin' ./configure --enable-threads
|
||||||
|
make libtkstub84.a
|
||||||
|
|
||||||
|
cd $SRCDIR/Togl2.1
|
||||||
|
env 'CC=gcc -mno-cygwin' ./configure --with-tcl=../tcl$VER/win --with-tk=../tk$VER/win
|
||||||
|
|
||||||
|
make
|
||||||
|
</code></pre></blockquote>
|
||||||
|
The resulting <code>Togl21.dll</code> and <code>pkgIndex.tcl</code>
|
||||||
|
should be installed into your Tcl installation just like any other package.
|
||||||
|
|
||||||
|
<p>
|
||||||
|
If you change all of the above <code>make</code>'s
|
||||||
|
to <code>make install</code> instead,
|
||||||
|
then the Togl package is installed correctly.
|
||||||
|
|
||||||
|
<h4><a name="macosx">Mac OS X usage</a></h4>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
These special instructions are for building the Aqua version of Togl.
|
||||||
|
Mac OS X needs <code>tkMacOSXInt.h</code>
|
||||||
|
and other internal Tk header files.
|
||||||
|
Unfortunately, the Tcl and Tk frameworks that Apple distributes
|
||||||
|
are missing the internal headers.
|
||||||
|
So you need a Tcl/Tk source distribution in addition to the Togl
|
||||||
|
distribution (or copy over the various include files).
|
||||||
|
You would probably want a newer version of Tcl and Tk anyway
|
||||||
|
because each minor revision of 8.4 has many Aqua bug fixes.
|
||||||
|
<p>
|
||||||
|
Here's one way to build Tcl, Tk, and Togl on Mac OS X
|
||||||
|
(assuming they are all in the same directory)
|
||||||
|
to install in your home directory:
|
||||||
|
<blockquote><pre><code>
|
||||||
|
VER=8.4.12
|
||||||
|
|
||||||
|
mkdir -p ~/bin
|
||||||
|
make -C tcl$VER/macosx install PREFIX="${HOME}" INSTALL_PATH="${HOME}/Library/Frameworks"
|
||||||
|
make -C tk$VER/macosx install PREFIX="${HOME}" INSTALL_PATH="${HOME}/Library/Frameworks" APPLICATION_INSTALL_PATH="${HOME}/Applications"
|
||||||
|
|
||||||
|
cd Togl2.1
|
||||||
|
./configure --prefix="${HOME}"
|
||||||
|
make install
|
||||||
|
</code></pre></blockquote>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<h2><a name="version">Version History</a></h2>
|
||||||
|
|
||||||
|
<h3>Version 1.0 — March, 1996</h3>
|
||||||
|
<ul>
|
||||||
|
<li>Initial version
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Version 1.1 (never officially released)</h3>
|
||||||
|
<ul>
|
||||||
|
<li>Added Togl_LoadBitmapFont function
|
||||||
|
<li>Fixed a few bugs
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Version 1.2 — November, 1996</h3>
|
||||||
|
<ul>
|
||||||
|
<li>added swapbuffers and makecurrent Tcl commands
|
||||||
|
<li>more bug fixes
|
||||||
|
<li>upgraded to suport Tcl 7.6 and Tk 4.2
|
||||||
|
<li>added stereo and overlay plane support
|
||||||
|
<li>added Togl_Get/SetClientData() functions
|
||||||
|
<li>added Togl_DestroyFunc()
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Version 1.3 — May 2, 1997</h3>
|
||||||
|
<ul>
|
||||||
|
<li>fixed a bug in Togl_Configure()
|
||||||
|
<li>fixed a compilation problem in using Tcl_PkgProvide() with Tcl < 7.4
|
||||||
|
<li>new overlay functions: Togl_ExistsOverlay, Togl_GetOverlayTransparentValue,
|
||||||
|
Togl_IsMappedOverlay, Togl_AllocColorOverlay, Togl_FreeColorOverlay
|
||||||
|
<li>added X11 functions: Togl_Display, Togl_Screen, Togl_ScreenNumber,
|
||||||
|
Togl_Colormap
|
||||||
|
<li>added Togl_DumpToEpsFile function
|
||||||
|
<li>fixed a C++ compilation problem
|
||||||
|
<li>more robust overlay code
|
||||||
|
<li>added timers (Togl_TimerFunc) from Peter Dern and Elmar Gerwalin
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Version 1.4 — September 17, 1997</h3>
|
||||||
|
<ul>
|
||||||
|
<li>ported to Microsoft Windows NT (Robert Casto)
|
||||||
|
<li>updated for Tcl/Tk 8.0
|
||||||
|
<li>added many config flags (-redsize, -depthsize, etc) (Matthias Ott)
|
||||||
|
<li>added Togl_Set*Func() functions to reassign callback functions (Matthias Ott)
|
||||||
|
<li>added Togl_ResetDefaultCallbacks() and Togl_ClientData() functions (Greg Couch)
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Version 1.5 — September 18, 1998</h3>
|
||||||
|
<ul>
|
||||||
|
<li>fixed a few Unix and Microsoft Windows compilation bugs
|
||||||
|
<li>added Ben Evan's SGI stereo functions
|
||||||
|
<li>multiple expose events now reduced to one redraw
|
||||||
|
<li>destroying Togl widgets caused problems, patched by Adrian J. Chung
|
||||||
|
<li>added Togl_TkWin() function
|
||||||
|
<li>updated for Tcl/Tk 8.0p2
|
||||||
|
<li>added gears demo from Philip Quaife
|
||||||
|
<li>added <code>-sharelist</code> and <code>-sharecontext</code> config flags
|
||||||
|
<li>fixed a few overlay update bugs
|
||||||
|
<li>added <code>-indirect</code> config flag
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Version 1.6 — May 7, 2003</h3>
|
||||||
|
<ul>
|
||||||
|
<li>added Togl_SetTimerFunc function
|
||||||
|
<li>updated for Tcl/Tk 8.0.5 and 8.1
|
||||||
|
<li>context sharing added for Microsoft Windows
|
||||||
|
<li>Macintosh support (by Paul Thiessen)
|
||||||
|
<li>Tcl/Tk stubs support — see README.tcl (by Jonas Beskow)
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Version 1.7 — January 6, 2006</h3>
|
||||||
|
<ul>
|
||||||
|
<li>added Mac OS X support
|
||||||
|
<li>enabled asking for quad-buffered stereo pixel formats on all platforms
|
||||||
|
(use -oldstereo on SGIs for splitscreen stereo — C API changed too)
|
||||||
|
<li>configuring the cursor is no longer slow
|
||||||
|
<li>added <code>-pixelformat</code> config flag
|
||||||
|
<li>added setgrid support (unfortunately many window managers can't cope with 1x1 pixel grid)
|
||||||
|
<li>only free context when last reference is gone
|
||||||
|
<li>switched to TEA-based configure (instead of editting make files)
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Version 2.0 — April 22, 2008</h3>
|
||||||
|
<ul>
|
||||||
|
<li>stubified C API
|
||||||
|
<li>replaced EPS support with TK photo image support
|
||||||
|
<li>simplified C API by requiring callback command options
|
||||||
|
<li>Added command arguments for create, destroy, etc. callbacks,
|
||||||
|
so there is a -createcommand option to the togl command (etc.).
|
||||||
|
(and removed Togl_*Func from the C API)
|
||||||
|
<li>added togl instance commands that call C API —
|
||||||
|
see <a href="tclapi.html">documentation</a>
|
||||||
|
<li>use Tcl objects internally
|
||||||
|
<li>use Tcl object interface for callbacks
|
||||||
|
<li>vertical sync control
|
||||||
|
<li>fix thread safety in anticipation that OpenGL drivers may someday be thread safe
|
||||||
|
<li>added simple stereo rendering interface
|
||||||
|
<li>revised font C API
|
||||||
|
<li>updated font support for Tk 8.4 on all platforms
|
||||||
|
<li>updated documentation
|
||||||
|
<li>prebuilt binaries
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Version 2.1 — December 2009 </h3>
|
||||||
|
<ul>
|
||||||
|
<li>incorporate the part of the X11R6 Xmu library that Togl uses
|
||||||
|
so it will work on (Linux) systems that don't have the Xmu shared library
|
||||||
|
<li>Mac OS X Aqua delete context bug fix
|
||||||
|
<li>multisampling support
|
||||||
|
<li>pbuffer support (Unix/X11, Microsoft Windows, Mac OS X)
|
||||||
|
<li>Ability to copy context state
|
||||||
|
<li>row interleaved stereo support
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<h3>Future plans</h3>
|
||||||
|
Patches for the following are especially welcome:
|
||||||
|
<ul>
|
||||||
|
<li>Tk 8.5 fonts
|
||||||
|
<li>Aqua Cocoa support (Tk 8.6b2)
|
||||||
|
<li>OpenGL 3 contexts
|
||||||
|
<li>EGL support
|
||||||
|
<li>RGB overlays
|
||||||
|
<li>Tcl access to colormap manipulation
|
||||||
|
<li>NVidia consumer stereo support
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<a href="http://sourceforge.net/projects/togl">
|
||||||
|
<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=519&type=13" width="120" height="30" border="0" alt="Get Togl at SourceForge.net. Fast, secure and Free Open Source software downloads">
|
||||||
|
</a>
|
||||||
|
<a href="http://validator.w3.org/check?uri=referer">
|
||||||
|
<img src="http://www.w3.org/Icons/valid-html401-blue"
|
||||||
|
alt="Valid HTML 4.01 Transitional" height="31" width="88" border="0">
|
||||||
|
</a>
|
||||||
|
</body>
|
||||||
|
</html>
|
112
ng/Togl2.1/doc/faq.html
Normal file
112
ng/Togl2.1/doc/faq.html
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<!-- vi:set sw=2: -->
|
||||||
|
<!--
|
||||||
|
Copyright (C) 1996-2002 Brian Paul and Ben Bederson
|
||||||
|
Copyright (C) 2005-2009 Greg Couch
|
||||||
|
See the LICENSE file for copyright details.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||||
|
<title>Togl Frequently Asked Questions</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<script type="text/javascript" src="header.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
NavigationBar();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h1 align="center">Togl Frequently Asked Questions</h1>
|
||||||
|
|
||||||
|
<h2>Contents</h2>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#badmatch">Bad Match X errors on Sun systems</a>
|
||||||
|
<li><a href="#stereo">Is stereo rendering supported?</a>
|
||||||
|
<li><a href="#fullscreen stereo">Is fullscreen stereo rendering supported?</a>
|
||||||
|
<li><a href="#dc">How do I get the Microsoft Windows device context?</a>
|
||||||
|
<li><a href="#python">How do I use Togl from Python?</a>
|
||||||
|
<li><a href="#tile">Is Togl compatible with Tile and Tk 8.5?</a>
|
||||||
|
</ul>
|
||||||
|
<h2>Frequently Asked Questions (and Problems)</h2>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
If you have something to add to this section please let us know.
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt>
|
||||||
|
<a name="badmatch"><b>Bad Match X errors on Sun systems</b></a>
|
||||||
|
<dd>
|
||||||
|
There is(was?) a bug in Sun's XmuLookupStandardColormap
|
||||||
|
X library function.
|
||||||
|
If you compile togl.c with the SOLARIS_BUG symbol defined (-DSOLARIS_BUG)
|
||||||
|
this function call will be omitted.
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<dt>
|
||||||
|
<a name="stereo"><b>Is stereo rendering supported?</b></a>
|
||||||
|
<dd>
|
||||||
|
Several different <a href="stereo.html">stereo modes</a> are supported.
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<dt>
|
||||||
|
<a name="fullscreen stereo"><b>Is fullscreen stereo rendering supported?</b></a>
|
||||||
|
<dd>
|
||||||
|
Before Tk 8.5,
|
||||||
|
Tk does not support true fullscreen windows.
|
||||||
|
Consequenly the full-screen stereo,
|
||||||
|
that gaming graphics cards support (ATI Radeon, NVidia GeForce),
|
||||||
|
won't be added until sometime after Tk 8.5 is available.
|
||||||
|
Fullscreen stereo on workstation graphics cards
|
||||||
|
(ATI FireGL, NVidia Quadro, Matrix Parhelia, 3Dlabs Wildcat)
|
||||||
|
does work.
|
||||||
|
<p>
|
||||||
|
<dt>
|
||||||
|
<a name="dc"><b>How do I get the Microsoft Windows device context?</b></a>
|
||||||
|
<dd>
|
||||||
|
First call <code>Togl_MakeCurrent</code> to make sure you have the
|
||||||
|
right OpenGL context and device context set,
|
||||||
|
then call <code>wglGetCurrentDC</code>.
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<dt>
|
||||||
|
<a name="python"><b>How do I use Togl from Python?</b></a>
|
||||||
|
<dd>
|
||||||
|
The Togl source distribution comes with a <code>Togl.py</code> file
|
||||||
|
that provides a Tkinter-style Togl widget.
|
||||||
|
And for Togl callbacks that are C functions,
|
||||||
|
there is a <code>toglpy.h</code> file that provides a function
|
||||||
|
that converts a Python object into its corresponding Togl widget:
|
||||||
|
<blockquote>
|
||||||
|
<code>Togl *getToglFromWidget(PyObject *widget)</code>
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<dt>
|
||||||
|
<a name="tile"><b>Is Togl compatible with Tile and Tk 8.5?</b></a>
|
||||||
|
<dd>
|
||||||
|
Yes, Togl works as is (except for the bitmap font support for X11 and Aqua).
|
||||||
|
From <a href="http://wiki.tcl.tk/1218">Joe English</a>:
|
||||||
|
<blockquote>
|
||||||
|
Complex "owner-draw" widgets like tkZinc,
|
||||||
|
or the text and canvas widgets,
|
||||||
|
really don't benefit much from themability,
|
||||||
|
so there's no reason to rewrite them.
|
||||||
|
(<a href="http://wiki.tcl.tk/13373">http://wiki.tcl.tk/13373</a>)
|
||||||
|
</blockquote>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<a href="http://sourceforge.net/projects/togl">
|
||||||
|
<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=519&type=13" width="120" height="30" border="0" alt="Get Togl at SourceForge.net. Fast, secure and Free Open Source software downloads">
|
||||||
|
</a>
|
||||||
|
<a href="http://validator.w3.org/check?uri=referer">
|
||||||
|
<img src="http://www.w3.org/Icons/valid-html401-blue"
|
||||||
|
alt="Valid HTML 4.01 Transitional" height="31" width="88" border="0">
|
||||||
|
</a>
|
||||||
|
</body>
|
||||||
|
</html>
|
20
ng/Togl2.1/doc/header.js
Normal file
20
ng/Togl2.1/doc/header.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
function displayHeader(pageTitle)
|
||||||
|
{
|
||||||
|
document.write("<center><h1>" + pageTitle + "</h1></center>");
|
||||||
|
}
|
||||||
|
|
||||||
|
function NavigationBar()
|
||||||
|
{
|
||||||
|
document.write("<table rules='cols' cellpadding='4'>");
|
||||||
|
document.write(" <tr>");
|
||||||
|
document.write(" <td><a href='index.html'>Index</a></td>");
|
||||||
|
document.write(" <td><a href='index.html#intro'>Intro</a></td>");
|
||||||
|
document.write(" <td><a href='download.html'>Download/Install</a></td>");
|
||||||
|
document.write(" <td><a href='using.html'>Using Togl</a></td>");
|
||||||
|
document.write(" <td><a href='tclapi.html'>Tcl API</a></td>");
|
||||||
|
document.write(" <td><a href='capi.html'>C API</a></td>");
|
||||||
|
document.write(" <td><a href='faq.html'>FAQ</a></td>");
|
||||||
|
document.write(" </tr>");
|
||||||
|
document.write("</table>");
|
||||||
|
document.write("<hr>");
|
||||||
|
}
|
150
ng/Togl2.1/doc/index.html
Normal file
150
ng/Togl2.1/doc/index.html
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<!-- vi:set sw=2: -->
|
||||||
|
<!--
|
||||||
|
Copyright (C) 1996-2002 Brian Paul and Ben Bederson
|
||||||
|
Copyright (C) 2005-2009 Greg Couch
|
||||||
|
See the LICENSE file for copyright details.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||||
|
<title>Togl, a Tk OpenGL widget</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<script type="text/javascript" src="header.js"></script>
|
||||||
|
|
||||||
|
<h1 align="center">Togl — a Tk OpenGL widget</h1>
|
||||||
|
<h3 align="center">Copyright © 1996-2009 Brian Paul, Ben Bederson, and Greg Couch</h3>
|
||||||
|
|
||||||
|
<h2>Index</h2>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><a href="#intro">Introduction</a>
|
||||||
|
<li><a href="download.html">Download/Installation</a>
|
||||||
|
<li><a href="using.html">Using the togl widget</a>
|
||||||
|
<ul>
|
||||||
|
<li><a href="tclapi.html">Tcl API</a>
|
||||||
|
<li><a href="capi.html">C API</a>
|
||||||
|
<li><a href="upgrading.html">Upgrading to version 2</a>
|
||||||
|
</ul>
|
||||||
|
<li><a href="faq.html">Frequently Asked Questions (FAQ)</a>
|
||||||
|
<li><a href="#mailing">Mailing List</a>
|
||||||
|
<li><a href="#bugs">Reporting Bugs</a>
|
||||||
|
<li><a href="#contrib">Contributors</a>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<h2><a name="intro">Introduction</a></h2>
|
||||||
|
|
||||||
|
Togl is a <a href="http://www.tcl.tk/">Tk</a> widget for
|
||||||
|
<a href="http://www.opengl.org/">OpenGL</a> rendering.
|
||||||
|
Togl was originally based on OGLTK, written by Benjamin Bederson at
|
||||||
|
the University of New Mexico.
|
||||||
|
|
||||||
|
Togl's main features are:
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>unifies Microsoft Windows, X11 (Linux/IRIX/...), and Mac OS X Aqua support
|
||||||
|
<li>support for requesting stencil, accumulation, alpha buffers, <i>etc</i>.
|
||||||
|
<li>multiple OpenGL drawing windows
|
||||||
|
<li>simple stereo rendering support
|
||||||
|
<li>simple, portable font support
|
||||||
|
<li>color-index mode support including color allocation functions
|
||||||
|
<li>overlay plane support
|
||||||
|
<li>OpenGL extension testing from Tcl
|
||||||
|
<li>Tcl Extension Architecture (TEA) 3 compliant
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Togl does almost no OpenGL drawing itself,
|
||||||
|
instead it manages OpenGL drawing by calling various Tcl commands
|
||||||
|
(<i>a.k.a.</i>, callback functions).
|
||||||
|
Those commands can be C functions that call OpenGL (in)directly
|
||||||
|
or another Tcl package
|
||||||
|
(<i>e.g.</i>, <a href="http://www.tcl3d.org/">Tcl3D</a>).
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Togl is copyrighted by
|
||||||
|
<a href="http://www.mesa3d.org/brianp/home.html">Brian Paul</a>
|
||||||
|
(brian_e_paulATyahooDOTcom),
|
||||||
|
<a href="http://www.cs.umd.edu/~bederson/">Benjamin Bederson</a>
|
||||||
|
(bedersonATcsDOTumdDOTedu), and
|
||||||
|
<a href="http://www.cgl.ucsf.edu/chimera/">Greg Couch</a>
|
||||||
|
(gregcouchATusersDOTsourceforgeDOTnet).
|
||||||
|
See the LICENSE file for details.
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The <a href="http://www.sourceforge.net/projects/togl/">
|
||||||
|
Togl project</a> and
|
||||||
|
<a href="http://togl.sourceforge.net">home page</a> are
|
||||||
|
hosted by <a href="http://www.sourceforge.net">SourceForge</a>.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<h2><a name="mailing">Mailing list</a></h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
See the <a href="http://www.sourceforge.net/projects/togl/">
|
||||||
|
Togl project at SourceForge</a> for mailing list information.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<h2><a name="bugs">Reporting Bugs</a></h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
There is a bug database on the
|
||||||
|
<a href="http://sourceforge.net/projects/togl/">Togl Project Page</a>.
|
||||||
|
You may also discuss bugs on the mailing list.
|
||||||
|
<p>
|
||||||
|
It may be worth upgrading your graphics driver and retesting
|
||||||
|
before reporting a bug,
|
||||||
|
as, historically,
|
||||||
|
many Togl "bugs" have been fixed by a graphics driver upgrade,
|
||||||
|
especially on Microsoft Windows.
|
||||||
|
<p>
|
||||||
|
When reporting bugs please provide as much information as possible.
|
||||||
|
Such as the version of Togl, which operating system
|
||||||
|
(<i>e,g.</i>, Microsoft Windows, Red Hat Linux, Mac OS X, <i>etc.</i>),
|
||||||
|
the version of the operating system,
|
||||||
|
and the version of the graphics driver.
|
||||||
|
Also, it's very helpful to us if you can provide an example program
|
||||||
|
which demonstrates the problem.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<h2><a name="contrib">Contributors</a></h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Several people have contributed new features to Togl. Among them are:
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>Ramon Ramsan — overlay plane support
|
||||||
|
<li>Miguel A. De Riera Pasenau — more overlay functions, X11 functions
|
||||||
|
and EPS output
|
||||||
|
<li>Peter Dern and Elmar Gerwalin — Togl_TimerFunc and related code
|
||||||
|
<li>Robert Casto — Microsoft Windows NT port
|
||||||
|
<li>Geza Groma — Microsoft Windows 95/NT patches
|
||||||
|
<li>Ben Evans — SGI stereo support
|
||||||
|
<li>Paul Thiessen — Macintosh support
|
||||||
|
<li>Jonas Beskow — Tcl/Tk stubs support
|
||||||
|
<li>Paul Kienzle — TEA debugging and patches
|
||||||
|
<li>Greg Couch — version 1.7, 2.0, 2.1
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
Many others have contributed bug fixes. Thanks for your contributions!
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<hr>
|
||||||
|
Last edited on 4 February 2009 by Greg Couch.
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<a href="http://sourceforge.net/projects/togl">
|
||||||
|
<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=519&type=13" width="120" height="30" border="0" alt="Get Togl at SourceForge.net. Fast, secure and Free Open Source software downloads">
|
||||||
|
</a>
|
||||||
|
<a href="http://validator.w3.org/check?uri=referer">
|
||||||
|
<img src="http://www.w3.org/Icons/valid-html401-blue"
|
||||||
|
alt="Valid HTML 4.01 Transitional" height="31" width="88" border="0">
|
||||||
|
</a>
|
||||||
|
</body>
|
||||||
|
</html>
|
171
ng/Togl2.1/doc/stereo.html
Normal file
171
ng/Togl2.1/doc/stereo.html
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<!-- vi:set sw=2: -->
|
||||||
|
<!--
|
||||||
|
Copyright (C) 1996-2002 Brian Paul and Ben Bederson
|
||||||
|
Copyright (C) 2005-2009 Greg Couch
|
||||||
|
See the LICENSE file for copyright details.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||||
|
<title>Togl Stereo Modes</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<script type="text/javascript" src="header.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
NavigationBar();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h1 align="center">Togl Stereo Modes</h1>
|
||||||
|
|
||||||
|
<h2>Contents</h2>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#none">none</a>
|
||||||
|
<li><a href="#native">native</a>
|
||||||
|
<li><a href="#anaglyph">anaglyph</a>
|
||||||
|
<li><a href="#cross">cross-eye</a>
|
||||||
|
<li><a href="#wall">wall-eye</a>
|
||||||
|
<li><a href="#dti">dti</a>
|
||||||
|
<li><a href="#row">row interleaved</a>
|
||||||
|
<li><a href="#left">left eye</a>
|
||||||
|
<li><a href="#right">right eye</a>
|
||||||
|
<li><a href="#sgioldstyle">sgioldstyle</a>
|
||||||
|
<!--
|
||||||
|
<li><a href="#nvidia">nvidia consumer stereo</a>
|
||||||
|
-->
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
There are lots of stereo modes in Togl because there are many ways to
|
||||||
|
draw stereo with different tradeoffs.
|
||||||
|
All of the stereo modes are choosen with the
|
||||||
|
<a href="tclapi.html#pixelformat">
|
||||||
|
<code>-stereo</code> configuration option</a>.
|
||||||
|
All of the non-native stereo techniques
|
||||||
|
are software-only and can be changed at anytime.
|
||||||
|
<p>
|
||||||
|
When using a non-native stereo mode, the OpenGL
|
||||||
|
<code>glDrawBuffer</code>, <code>glClear</code>,
|
||||||
|
<code>glFrustum</code>, and <code>glOrtho</code> calls
|
||||||
|
should be replaced with the Togl
|
||||||
|
<a href="tclapi.html#stereo cmds">Tcl</a> or
|
||||||
|
<a href="capi.html#stereo">C</a> versions
|
||||||
|
for seemless stereo rendering.
|
||||||
|
<p>
|
||||||
|
The various stereo modes are:
|
||||||
|
<dl>
|
||||||
|
<dt>
|
||||||
|
<a name="none"></a><code>none</code> <i>or</i> "" <i>or any false boolean value</i>
|
||||||
|
<dd>
|
||||||
|
Turn off stereo.
|
||||||
|
<dt><code>native</code> <i>or any true boolean value</i>
|
||||||
|
<dd>
|
||||||
|
Use native OpenGL hardware accelerated stereo
|
||||||
|
(single- or double-buffered for both the left and the right eyes).
|
||||||
|
Each eye is drawn at full window resolution
|
||||||
|
which gives the best stereo image.
|
||||||
|
This mode requires support from the graphics driver and is
|
||||||
|
typically only supported on workstation-class graphics cards, <i>e.g.</i>,
|
||||||
|
<a href="http://www.nvidia.com/page/workstation.html">NVidia Quadro</a>,
|
||||||
|
<a href="http://ati.amd.com/products/workstation.html">ATI FireGL</a>,
|
||||||
|
<a href="http://www.matrox.com/graphics/">Matrix Parhelia</a>,
|
||||||
|
<a href="http://www.3dlabs.com/content/wildcat.asp">3DLabs Wildcat</a>
|
||||||
|
graphics cards
|
||||||
|
and <a href="http://www.sgi.com/">SGI</a> workstations.
|
||||||
|
The video refresh rate is changed automatically by the windowing system
|
||||||
|
except on SGI workstations.
|
||||||
|
Developers for SGI workstations can either switch the video manually with
|
||||||
|
<code>/usr/gfx/setmon</code> or <code>/usr/bin/X11/xsetmon</code>, or use the
|
||||||
|
<a href="http://www.cgl.ucsf.edu/Overview/software.html#autostereo">
|
||||||
|
autostereo</a> package.
|
||||||
|
<p>
|
||||||
|
Currently, there is a limitation that a togl widget can not be
|
||||||
|
reconfigured in or out of the native stereo mode.
|
||||||
|
And if/when it is supported,
|
||||||
|
some graphics drivers might not allow it.
|
||||||
|
<dt>
|
||||||
|
<a name="anaglyph"></a><code>anaglyph</code>
|
||||||
|
<dd>
|
||||||
|
Draw the left eye in the red part of the color buffer
|
||||||
|
and the right eye in the blue and green parts.
|
||||||
|
Designed to be viewed with inexpensive red-blue or red-cyan glasses.
|
||||||
|
Works best with gray scale and non-saturated color images.
|
||||||
|
<dt>
|
||||||
|
<a name="cross"></a><code>cross-eye</code>
|
||||||
|
<dd>
|
||||||
|
Draw right eye image on the left half of screen,
|
||||||
|
and draw left eye image on the right half of screen.
|
||||||
|
So each eye is drawn at less than half of the window resolution.
|
||||||
|
<dt>
|
||||||
|
<a name="wall"></a><code>wall-eye</code>
|
||||||
|
<dd>
|
||||||
|
Draw left eye image on the left half of the screen,
|
||||||
|
and draw right eye image on the right half of the screen.
|
||||||
|
So each eye is drawn at less than half of the window resolution.
|
||||||
|
<dt>
|
||||||
|
<a name="dti"></a><code>dti</code>
|
||||||
|
<dd>
|
||||||
|
Designed for <a href="http://www.dti3d.com/">DTI</a> displays.
|
||||||
|
If you look at the window unassisted,
|
||||||
|
you'll see horizonally squished images
|
||||||
|
with the left eye image on the left,
|
||||||
|
and right eye image on the right.
|
||||||
|
So each eye is drawn at half of the window resolution.
|
||||||
|
<dt>
|
||||||
|
<a name="row"></a><code>row interleaved</code>
|
||||||
|
<dd>
|
||||||
|
Designed for
|
||||||
|
<a href="http://www.vrex.com/">VRex</a>,
|
||||||
|
<a href="http://www.zalman.co.kr/">Zalman</a>, and
|
||||||
|
<a href="http://www.hyundaiq.com/">Hyundai</a> displays.
|
||||||
|
Where the right eye is on the even scanlines
|
||||||
|
and the left is on the odd ones.
|
||||||
|
Requires that there be a stencil buffer
|
||||||
|
and uses the most significant stencil bit.
|
||||||
|
Changes to the stencil state should be placed within
|
||||||
|
<a href="http://www.opengl.org/sdk/docs/man/xhtml/glPushAttrib.xml">
|
||||||
|
glPushAttrib</a>(GL_STENCIL_BUFFER_BIT) and glPopAttrib() calls.
|
||||||
|
<dt>
|
||||||
|
<a name="left"></a><code>left eye</code>
|
||||||
|
<dd>
|
||||||
|
Only draw left eye view at full resolution.
|
||||||
|
<dt>
|
||||||
|
<a name="right"></a><code>right eye</code>
|
||||||
|
<dd>
|
||||||
|
Only draw right eye view at full resolution.
|
||||||
|
<dt>
|
||||||
|
<a name="sgioldstyle"></a><code>sgioldstyle</code>
|
||||||
|
<dd>
|
||||||
|
Support older-style SGI stereo where you lose half of the vertical resolution.
|
||||||
|
This uses the SGIStereo X extension,
|
||||||
|
that is only available on SGI workstations,
|
||||||
|
to tell the X server to duplicate non-stereo windows into both eyes.
|
||||||
|
This option only works when the monitor has been changed to the one
|
||||||
|
of the <code>str_top</code>, <code>str_bot</code>, or <code>str_rect</code> video output modes.
|
||||||
|
<!--
|
||||||
|
<dt>
|
||||||
|
<a name="nvidia"></a><code>nvidia consumer stereo</code>
|
||||||
|
<dd>
|
||||||
|
Use the
|
||||||
|
<a href="http://www.nvidia.com/drivers">NVidia Consumer 3D Stereo</a> driver.
|
||||||
|
This only works with NVidia consumer graphics cards on Microsoft Windows
|
||||||
|
and when the Togl window covers the full screen.
|
||||||
|
NVidia Quadro users should use the <code>native</code> stereo mode.
|
||||||
|
-->
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<a href="http://sourceforge.net/projects/togl">
|
||||||
|
<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=519&type=13" width="120" height="30" border="0" alt="Get Togl at SourceForge.net. Fast, secure and Free Open Source software downloads">
|
||||||
|
</a>
|
||||||
|
<a href="http://validator.w3.org/check?uri=referer">
|
||||||
|
<img src="http://www.w3.org/Icons/valid-html401-blue"
|
||||||
|
alt="Valid HTML 4.01 Transitional" height="31" width="88" border="0">
|
||||||
|
</a>
|
||||||
|
</body>
|
||||||
|
</html>
|
774
ng/Togl2.1/doc/tclapi.html
Normal file
774
ng/Togl2.1/doc/tclapi.html
Normal file
@ -0,0 +1,774 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<!-- vi:set sw=2: -->
|
||||||
|
<!--
|
||||||
|
Copyright (C) 1996-2002 Brian Paul and Ben Bederson
|
||||||
|
Copyright (C) 2005-2009 Greg Couch
|
||||||
|
See the LICENSE file for copyright details.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||||
|
<title>Togl Tcl API</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<script type="text/javascript" src="header.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
NavigationBar();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h1 align="center">Togl Tcl API</h1>
|
||||||
|
|
||||||
|
<h2>Contents</h2>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#tclfuncs">Togl Tcl command</a>
|
||||||
|
<li><a href="#toglfuncs">Togl widget commands</a>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#configuration">Configuration Commands</a>
|
||||||
|
<li><a href="#extensions">Extensions Command</a>
|
||||||
|
<li><a href="#rendering">Rendering Commands</a>
|
||||||
|
<li><a href="#image">Image Commands</a>
|
||||||
|
<li><a href="#font">Font Commands</a>
|
||||||
|
<li><a href="#overlay">Overlay Commands</a>
|
||||||
|
<li><a href="#stereo cmds">OpenGL (Stereo) Commands</a>
|
||||||
|
</ul>
|
||||||
|
<li><a href="#options">Togl configuration options</a>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#drawing">Drawing callbacks</a>
|
||||||
|
<li><a href="#geometry">Geometry Options</a>
|
||||||
|
<li><a href="#timer">Timer Options</a>
|
||||||
|
<li><a href="#stereo options">Stereo Options</a>
|
||||||
|
<li><a href="#miscellaneous">Miscellaneous Options</a>
|
||||||
|
<li><a href="#pixelformat">Pixel Format Options</a>
|
||||||
|
</ul>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<h2><a name="tclfuncs">Togl Tcl command</a></h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The togl command creates a new Tk widget, a Tcl command,
|
||||||
|
whose name is <var>pathName</var>.
|
||||||
|
This command may be used to invoke various operations on the widget.
|
||||||
|
<blockquote>
|
||||||
|
<code>togl <var>pathName</var> [<a href="#options">options</a>]</code>
|
||||||
|
</blockquote>
|
||||||
|
If no options are given, a 400 by 400 pixel RGB window is created.
|
||||||
|
This command may be used to invoke various operations on the widget.
|
||||||
|
|
||||||
|
<h2><a name="toglfuncs">Togl widget commands</a></h2>
|
||||||
|
|
||||||
|
The following commands are possible for an existing togl widget:
|
||||||
|
|
||||||
|
<h3><a name="configuration">Configuration commands</a></h3>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> cget <var>-option</var></code>
|
||||||
|
<dd>
|
||||||
|
Return current value of given configuration option.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt>
|
||||||
|
<code><var>pathName</var> configure</code><br>
|
||||||
|
<code><var>pathName</var> configure <var>-option</var></code>
|
||||||
|
<dd>
|
||||||
|
If no <var>option</var> is given,
|
||||||
|
then return information about
|
||||||
|
all configuration <a href="#options">options</a>.
|
||||||
|
Otherwise,
|
||||||
|
return configuration information for given <var>option</var>.
|
||||||
|
All configuration information consists of five values:
|
||||||
|
the configuration option name,
|
||||||
|
the option database name,
|
||||||
|
the option database class,
|
||||||
|
the default value,
|
||||||
|
and the current value.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> configure <var>-option</var> <var>value</var></code>
|
||||||
|
<dd>
|
||||||
|
Reconfigure a Togl widget.
|
||||||
|
<var>option</var> may be any one of the options listed below.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> contexttag</code>
|
||||||
|
<dd>
|
||||||
|
Returns an integer that represents the context tag.
|
||||||
|
All Togl widgets with the same context tag share display lists.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<h3><a name="extensions">Extensions command</a></h3>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> extensions</code>
|
||||||
|
<dd>
|
||||||
|
Returns a list of OpenGL extensions available. For example:
|
||||||
|
<blockquote><pre><code>
|
||||||
|
if {[lsearch [<i>pathName</i> extensions] GL_EXT_bgra] != -1]} {
|
||||||
|
....
|
||||||
|
}
|
||||||
|
</code></pre></blockquote>
|
||||||
|
would check if the GL_EXT_bgra extension were supported.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<h3><a name="rendering">Rendering commands</a></h3>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> postredisplay</code>
|
||||||
|
<dd>
|
||||||
|
Cause the displaycommand callback to be called
|
||||||
|
the next time the event loop is idle.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> render</code>
|
||||||
|
<dd>
|
||||||
|
Causes the displaycommand callback to be called for <var>pathName</var>.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> swapbuffers</code>
|
||||||
|
<dd>
|
||||||
|
Causes front/back buffers to be swapped if in double buffer mode.
|
||||||
|
And flushs the OpenGL command buffer if in single buffer mode.
|
||||||
|
(So this is appropriate to call after every frame is drawn.)
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> makecurrent</code>
|
||||||
|
<dd>
|
||||||
|
Make the widget specified by <var>pathName</var> and its OpenGL context
|
||||||
|
the current ones.
|
||||||
|
This is implicitly called before any callback command is invoked.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> copycontextto <var>toPathName</var> <var>mask</var></code>
|
||||||
|
<dd>
|
||||||
|
Copy a subset of the OpenGL context state from <var>pathName</var> to
|
||||||
|
<var>toPathName</var> according the given mask.
|
||||||
|
The mask is an integer corresponding to the same values as
|
||||||
|
<a href="http://www.opengl.org/sdk/docs/man/xhtml/glPushAttrib.xml">
|
||||||
|
glPushAttrib</a>.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<h3><a name="image">Image commands</a></h3>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> takephoto <var>imagename</var></code>
|
||||||
|
<dd>
|
||||||
|
Copy the contents of the togl window into the given Tk photo image.
|
||||||
|
Transparency values are copied and should be fully opaque for windows
|
||||||
|
without alpha bitplanes.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<h3><a name="font">Font commands</a></h3>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
These functions provide an interface to the simple bitmap font capabilities
|
||||||
|
that every OpenGL implementation provides.
|
||||||
|
Better font support is found in other packages, <i>e.g.</i>,
|
||||||
|
<a href="http://www.tcl3d.org/">Tcl3D</a>
|
||||||
|
or with different <a href="capi.html#font">C APIs</a>.
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> loadbitmapfont <var>font</var></code>
|
||||||
|
<dd>
|
||||||
|
<var>font</var> can be any of font descriptions listed in the Tk
|
||||||
|
<a href="http://www.tcl.tk/man/tcl8.4/TkCmd/font.htm#M13">font</a> command.
|
||||||
|
It returns a togl font object.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> unloadbitmapfont <var>toglfont</var></code>
|
||||||
|
<dd>
|
||||||
|
Releases the OpenGL resources needed by the <var>toglfont</var>.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> write <var>toglfont</var> [-pos <var>xyzw</var>] [-color <var>rgba</var>] <var>string</var></code>
|
||||||
|
<dd>
|
||||||
|
Write the given <var>string</var> in the given <var>toglfont</var>,
|
||||||
|
optionally at a particular position, <var>xyzw</var>
|
||||||
|
and color, <var>rgba</var>.
|
||||||
|
<var>xyzw</var> is either a 2, 3, or 4 element list of numbers.
|
||||||
|
<var>rgba</var> is either a 3 or 4 element list of numbers.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<h3><a name="overlay">Overlay Commands</a></h3>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> uselayer <var>layer</var></code>
|
||||||
|
<dd>
|
||||||
|
This is a variation on the <code>makecurrent</code> command
|
||||||
|
that makes the overlay OpenGL context current
|
||||||
|
if <var>layer</var> is 2
|
||||||
|
and makes the normal OpenGL context current
|
||||||
|
if <var>layer</var> is 1.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> showoverlay</code>
|
||||||
|
<dd>
|
||||||
|
Turn on drawing in the overlay planes.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> hideoverlay</code>
|
||||||
|
<dd>
|
||||||
|
Turn off drawing in the overlay planes.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> postredisplayoverlay</code>
|
||||||
|
<dd>
|
||||||
|
Cause the overlay OpenGL context to be redrawn the next time
|
||||||
|
the Tcl event loop is idle.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> renderoverlay</code>
|
||||||
|
<dd>
|
||||||
|
Causes the overlaydisplaycommand callback to be called for <var>pathName</var>.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> existsoverlay</code>
|
||||||
|
<dd>
|
||||||
|
Return true if togl widget has overlay planes.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> ismappedoverlay</code>
|
||||||
|
<dd>
|
||||||
|
Return true if overlay planes are shown.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> getoverlaytransparentvalue</code>
|
||||||
|
<dd>
|
||||||
|
Return overlay plane's transparent pixel value.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<h3><a name="stereo cmds">OpenGL (Stereo) Commands</a></h3>
|
||||||
|
These commands exist to support stereo rendering.
|
||||||
|
Just replace select OpenGL calls with the Togl versions
|
||||||
|
and stereo rendering will magically work. And don't forget
|
||||||
|
to update the <a href="#stereo options">stereo options</a>.
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> drawbuffer <var>mode</var></code>
|
||||||
|
<dd>
|
||||||
|
Replaces calls to
|
||||||
|
<a href="http://www.opengl.org/sdk/docs/man/xhtml/glDrawBuffer.xml">
|
||||||
|
glDrawBuffer</a>.
|
||||||
|
The mode is an integer.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> clear <var>mask</var></code>
|
||||||
|
<dd>
|
||||||
|
Replaces calls to
|
||||||
|
<a href="http://www.opengl.org/sdk/docs/man/xhtml/glClear.xml">
|
||||||
|
glClear</a>.
|
||||||
|
The mask is an integer.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> frustum <var>left right bottom top near far</var></code>
|
||||||
|
<dd>
|
||||||
|
Replaces calls to
|
||||||
|
<a href="http://www.opengl.org/sdk/docs/man/xhtml/glFrustum.xml">
|
||||||
|
glFrustum</a>.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> ortho <var>left right bottom top near far</var></code>
|
||||||
|
<dd>
|
||||||
|
Replaces calls to
|
||||||
|
<a href="http://www.opengl.org/sdk/docs/man/xhtml/glOrtho.xml">
|
||||||
|
glOrtho</a>.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><code><var>pathName</var> numeyes</code>
|
||||||
|
<dd>
|
||||||
|
Returns numbers of eyes — basically,
|
||||||
|
2 for stereo views and 1 for all others,
|
||||||
|
except some stereo views only need one eye from OpenGL.
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<h2><a name="options">Togl configuration options</a></h2>
|
||||||
|
|
||||||
|
Togl's configuration options can be separated into several categories:
|
||||||
|
geometry, pixel format, and other.
|
||||||
|
The pixel format related options can only be set at widget creation time.
|
||||||
|
The other options can be changed dynamically
|
||||||
|
by the <code><var>pathName</var> configure</code> command (see above).
|
||||||
|
|
||||||
|
<h3><a name="drawing">Drawing callbacks</a></h3>
|
||||||
|
|
||||||
|
<table border="0">
|
||||||
|
<thead>
|
||||||
|
<tr valign="top">
|
||||||
|
<th>Option</th>
|
||||||
|
<th>Default</th>
|
||||||
|
<th>Comments</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-createcommand</code></td>
|
||||||
|
<td align="center">{}</td>
|
||||||
|
<td>
|
||||||
|
Can be abbreviated <code>-create</code>.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-displaycommand</code></td>
|
||||||
|
<td align="center">{}</td>
|
||||||
|
<td>
|
||||||
|
Can be abbreviated <code>-display</code>.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-reshapecommand</code></td>
|
||||||
|
<td align="center">{}</td>
|
||||||
|
<td>
|
||||||
|
Can be abbreviated <code>-reshape</code>.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-destroycommand</code></td>
|
||||||
|
<td align="center">{}</td>
|
||||||
|
<td>
|
||||||
|
Can be abbreviated <code>-destroy</code>.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-overlaydisplaycommand</code></td>
|
||||||
|
<td align="center">{}</td>
|
||||||
|
<td>
|
||||||
|
Can be abbreviated <code>-overlaydisplay</code>.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h3><a name="geometry">Geometry Options</a></h3>
|
||||||
|
|
||||||
|
<table border="0">
|
||||||
|
<thead>
|
||||||
|
<tr valign="top">
|
||||||
|
<th>Option</th>
|
||||||
|
<th>Default</th>
|
||||||
|
<th>Comments</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-width</code></td>
|
||||||
|
<td align="center">400</td>
|
||||||
|
<td>
|
||||||
|
Set width of widget in pixels.
|
||||||
|
It may have any of the forms accepted by <b>Tk_GetPixels</b>.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-height</code></td>
|
||||||
|
<td align="center">400</td>
|
||||||
|
<td>
|
||||||
|
Set height of widget in pixels.
|
||||||
|
It may have any of the forms accepted by <b>Tk_GetPixels</b>(3).
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-setgrid</code></td>
|
||||||
|
<td align="center">0</td>
|
||||||
|
<td>
|
||||||
|
Turn on gridded geometry management for togl widget's toplevel
|
||||||
|
window and specify the geometry of the grid.
|
||||||
|
See the manual pages for Tk's <b>wm</b>(n) and <b>Tk_SetGrid</b>(3)
|
||||||
|
for more information.
|
||||||
|
Unlike the <b>text</b> widget,
|
||||||
|
the same value is used for both width and height increments.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h3><a name="timer">Timer Options</a></h3>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr valign="top">
|
||||||
|
<th>Option</th>
|
||||||
|
<th>Default</th>
|
||||||
|
<th>Comments</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-time</code></td>
|
||||||
|
<td align="center">1</td>
|
||||||
|
<td>
|
||||||
|
Specifies the interval, in milliseconds, for
|
||||||
|
calling the timer callback function which
|
||||||
|
was registered with -timercommand.</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-timercommand</code></td>
|
||||||
|
<td align="center">{}</td>
|
||||||
|
<td>
|
||||||
|
Can be abbreviated <code>-timer</code>.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h3><a name="stereo options">Stereo Options</a></h3>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr valign="top">
|
||||||
|
<th>Option</th>
|
||||||
|
<th>Default</th>
|
||||||
|
<th>Comments</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-eyeseparation</code></td>
|
||||||
|
<td align="center">2.0</td>
|
||||||
|
<td>
|
||||||
|
Set the distance between the eyes in viewing coordinates.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-convergence</code></td>
|
||||||
|
<td align="center">30.0</td>
|
||||||
|
<td>
|
||||||
|
Set the distance to the screen from the eye in viewing coordinates
|
||||||
|
(the distance at which the eyes converge).
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<blockquote>
|
||||||
|
You'd think these values would be given in physical units,
|
||||||
|
but there's no single right way to convert to viewing coordinates
|
||||||
|
from physical units.
|
||||||
|
So if you're willing to use Tk's idea of the horizontal size of a
|
||||||
|
window in millimeters (not always correct),
|
||||||
|
you could convert the average eye separation of 63 mm
|
||||||
|
to your viewing coordinates, and use that value as the eye separation.
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
|
<h3><a name="miscellaneous">Miscellaneous Options</a></h3>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr valign="top">
|
||||||
|
<th>Option</th>
|
||||||
|
<th>Default</th>
|
||||||
|
<th>Comments</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-cursor</code></td>
|
||||||
|
<td align="center">""</td>
|
||||||
|
<td>
|
||||||
|
Set the cursor in the widget window.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-swapinterval</code></td>
|
||||||
|
<td align="center">1</td>
|
||||||
|
<td>
|
||||||
|
Set the minimum swap interval measure in video frame periods.
|
||||||
|
The default is 1 for for non-tearing artifacts
|
||||||
|
when swapping buffers.
|
||||||
|
Use a value of 0 when benchmarking frame rates.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-ident</code></td>
|
||||||
|
<td align="center">""</td>
|
||||||
|
<td>
|
||||||
|
A user identification string. This is used match widgets
|
||||||
|
for the <code>-sharecontext</code>
|
||||||
|
and the <code>-sharelist</code> options (see below).
|
||||||
|
This is also useful in your callback functions
|
||||||
|
to determine which Togl widget is the caller.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h3><a name="pixelformat">Pixel Format Options</a></h3>
|
||||||
|
|
||||||
|
The following options can only be given when the togl widget is created
|
||||||
|
— that is, unlike other options,
|
||||||
|
the togl widget can not be reconfigured with different values
|
||||||
|
for the following options after it is created.
|
||||||
|
|
||||||
|
<table border="0">
|
||||||
|
<thead>
|
||||||
|
<tr valign="top">
|
||||||
|
<th>Option</th>
|
||||||
|
<th>Default</th>
|
||||||
|
<th>Comments</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-rgba</code></td>
|
||||||
|
<td align="center">true</td>
|
||||||
|
<td>If true, use RGB(A) mode, otherwise use Color Index mode.</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-redsize</code></td>
|
||||||
|
<td align="center">1</td>
|
||||||
|
<td>Minimum number of bits in red component.</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td nowrap="nowrap"><code>-greensize</code></td>
|
||||||
|
<td align="center">1</td>
|
||||||
|
<td>Minimum number of bits in green component.</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-bluesize</code></td>
|
||||||
|
<td align="center">1</td>
|
||||||
|
<td>Minimum number of bits in blue component.</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-alpha</code></td>
|
||||||
|
<td align="center">1</td>
|
||||||
|
<td>
|
||||||
|
If true and <code>-rgba</code> is true, request an alpha channel.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-alphasize</code></td>
|
||||||
|
<td align="center">1</td>
|
||||||
|
<td>Minimum number of bits in alpha component.</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr><td colspan="3"> </td></tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-double</code></td>
|
||||||
|
<td align="center">false</td>
|
||||||
|
<td>
|
||||||
|
If true, request a double-buffered window, otherwise
|
||||||
|
request a single-buffered window.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr><td colspan="3"> </td></tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-depth</code></td>
|
||||||
|
<td align="center">false</td>
|
||||||
|
<td>If true, request a depth buffer.</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-depthsize</code></td>
|
||||||
|
<td align="center">1</td>
|
||||||
|
<td>Minimum number of bits in depth buffer.</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr><td colspan="3"> </td></tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-accum</code></td>
|
||||||
|
<td align="center">false</td>
|
||||||
|
<td>If true, request an accumulation buffer.</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-accumredsize</code></td>
|
||||||
|
<td align="center">1</td>
|
||||||
|
<td>Minimum number of bits in accumulation buffer red component.</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td nowrap="nowrap"><code>-accumgreensize</code></td>
|
||||||
|
<td align="center">1</td>
|
||||||
|
<td>
|
||||||
|
Minimum number of bits in accumulation buffer green component.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-accumbluesize</code></td>
|
||||||
|
<td align="center">1</td>
|
||||||
|
<td>Minimum number of bits in accumulation buffer blue component.</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-accumalphasize</code></td>
|
||||||
|
<td align="center">1</td>
|
||||||
|
<td>
|
||||||
|
Minimum number of bits in accumulation buffer alpha component.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr><td colspan="3"> </td></tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-stencil</code></td>
|
||||||
|
<td align="center">false</td>
|
||||||
|
<td>If true, request a stencil buffer.</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-stencilsize</code></td>
|
||||||
|
<td align="center">1</td>
|
||||||
|
<td>Minimum number of bits in stencil component.</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr><td colspan="3"> </td></tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-auxbuffers</code></td>
|
||||||
|
<td align="center">0</td>
|
||||||
|
<td>Desired number of auxiliary buffers.</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr><td colspan="3"> </td></tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-privatecmap</code></td>
|
||||||
|
<td align="center">false</td>
|
||||||
|
<td>
|
||||||
|
Only applicable in color index mode.
|
||||||
|
If false, use a shared read-only colormap.
|
||||||
|
If true, use a private read/write colormap.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr><td colspan="3"> </td></tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-overlay</code></td>
|
||||||
|
<td align="center">false</td>
|
||||||
|
<td>If true, request overlay planes.</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr><td colspan="3"> </td></tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-stereo</code></td>
|
||||||
|
<td align="center">mode</td>
|
||||||
|
<td>
|
||||||
|
See the <a href="stereo.html">stereo</a> information
|
||||||
|
for details about the various modes.
|
||||||
|
Stereo parameters are changed with the
|
||||||
|
<a href="#stereo options">stereo options</a>.
|
||||||
|
<p>
|
||||||
|
When using a non-native stereo mode, the OpenGL
|
||||||
|
<a href="http://www.opengl.org/sdk/docs/man/xhtml/glDrawBuffer.xml">
|
||||||
|
glDrawBuffer</a>,
|
||||||
|
<a href="http://www.opengl.org/sdk/docs/man/xhtml/glClear.xml">
|
||||||
|
glClear</a>,
|
||||||
|
<a href="http://www.opengl.org/sdk/docs/man/xhtml/glFrustum.xml">
|
||||||
|
glFrustum</a>, and
|
||||||
|
<a href="http://www.opengl.org/sdk/docs/man/xhtml/glOrtho.xml">
|
||||||
|
glOrtho</a> calls
|
||||||
|
must be replaced with the Togl
|
||||||
|
<a href="#stereo cmds">Tcl</a> or
|
||||||
|
<a href="capi.html#stereo">C</a> versions.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr><td colspan="3" height="0"> </td></tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-pbuffer</code></td>
|
||||||
|
<td align="center">false</td>
|
||||||
|
<td>
|
||||||
|
If true, request off-screen framebuffer memory for the graphics.
|
||||||
|
The resulting togl widget should not be managed.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>-largestpbuffer</code></td>
|
||||||
|
<td align="center">false</td>
|
||||||
|
<td>
|
||||||
|
If true, when asking for a pbuffer of a given size
|
||||||
|
and there isn't enough framebuffer memory available,
|
||||||
|
fallback to the largest size available.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr><td colspan="3" height="0"> </td></tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-multisample</code></td>
|
||||||
|
<td align="center">false</td>
|
||||||
|
<td>
|
||||||
|
If true, request an multisampled rendering context.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-fullscreen</code></td>
|
||||||
|
<td align="center">false</td>
|
||||||
|
<td>
|
||||||
|
If true, request an multisampled rendering context.
|
||||||
|
<em>Requires Tcl/Tk 8.5 or newer on UNIX and Microsoft Windows platforms.</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
-->
|
||||||
|
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-indirect</code></td>
|
||||||
|
<td align="center">false</td>
|
||||||
|
<td>
|
||||||
|
If present, request an indirect rendering context.
|
||||||
|
A direct rendering context is normally requested.
|
||||||
|
<em>Only significant on Unix/X11.</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-sharelist</code></td>
|
||||||
|
<td align="center">""</td>
|
||||||
|
<td>
|
||||||
|
Togl identification string or window path name
|
||||||
|
of an existing Togl widget with which to share display lists.
|
||||||
|
If it is not possible to share display lists
|
||||||
|
between the two togl widgets
|
||||||
|
(depends on the graphics driver and the particular formats),
|
||||||
|
it fails.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-sharecontext</code></td>
|
||||||
|
<td align="center">""</td>
|
||||||
|
<td>
|
||||||
|
Togl identification string or window path name
|
||||||
|
of an existing Togl widget with which to share the OpenGL context.
|
||||||
|
<i>Note: all other pixel format options are ignored.</i>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<td><code>-pixelformat</code></td>
|
||||||
|
<td align="center">0</td>
|
||||||
|
<td>
|
||||||
|
Set the pixel format to the (platform-dependent) given value.
|
||||||
|
This is a backdoor into choosing a particular pixel format
|
||||||
|
that was determined by other means.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<a href="http://sourceforge.net/projects/togl">
|
||||||
|
<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=519&type=13" width="120" height="30" border="0" alt="Get Togl at SourceForge.net. Fast, secure and Free Open Source software downloads">
|
||||||
|
</a>
|
||||||
|
<a href="http://validator.w3.org/check?uri=referer">
|
||||||
|
<img src="http://www.w3.org/Icons/valid-html401-blue"
|
||||||
|
alt="Valid HTML 4.01 Transitional" height="31" width="88" border="0">
|
||||||
|
</a>
|
||||||
|
</body>
|
||||||
|
</html>
|
109
ng/Togl2.1/doc/upgrading.html
Normal file
109
ng/Togl2.1/doc/upgrading.html
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<!-- vi:set sw=2: -->
|
||||||
|
<!--
|
||||||
|
Copyright (C) 1996-2002 Brian Paul and Ben Bederson
|
||||||
|
Copyright (C) 2005-2009 Greg Couch
|
||||||
|
See the LICENSE file for copyright details.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||||
|
<title>Upgrading to Version 2</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<script type="text/javascript" src="header.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
NavigationBar();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h1 align="center">Upgrading to Version 2</h1>
|
||||||
|
|
||||||
|
<h2>Contents</h2>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#callbacks">Widget callback changes</a>
|
||||||
|
<li><a href="#subcommands">Widget subcommand changes</a>
|
||||||
|
<li><a href="#stereo">Stereo changes</a>
|
||||||
|
<li><a href="#fonts">Font API changes</a>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Internally, Togl version 2 isn't very different from version 1,
|
||||||
|
and much of the C interface is the same.
|
||||||
|
The main difference is that the focus of the Togl API has changed
|
||||||
|
from being a C API to being a Tcl API.
|
||||||
|
Which means that the full power of Togl is accessible from Tcl
|
||||||
|
(the few exceptions are considered bugs).
|
||||||
|
|
||||||
|
<h2><a name="callbacks">Widget callback changes</a></h2>
|
||||||
|
|
||||||
|
The biggest change is how the various callback are initialized.
|
||||||
|
In version 1,
|
||||||
|
the C API Togl_Set*Func functions had to be used
|
||||||
|
to setup the callback functions before creating the Togl widget.
|
||||||
|
And once the callbacks were set for a particular Togl widget,
|
||||||
|
they could not be changed.
|
||||||
|
If more than once Togl widget was needed,
|
||||||
|
the callback functions would need to be reset before each widget creation.
|
||||||
|
In version 2,
|
||||||
|
the callbacks are configuration arguments to the widget
|
||||||
|
and can be updated like any other standard widget configuration option.
|
||||||
|
See the <a href="tclapi.html">Tcl API</a> for details.
|
||||||
|
|
||||||
|
<h2><a name="subcommands">Widget subcommand changes</a></h2>
|
||||||
|
|
||||||
|
Version 1 also allowed new subcommands to be added
|
||||||
|
to the togl widget command via the C API.
|
||||||
|
This was dropped for a variety of reasons:
|
||||||
|
there is no exact Tcl equivalent,
|
||||||
|
there is no standard object-oriented technique
|
||||||
|
currently in the Tcl core (8.4.13),
|
||||||
|
it is unclear how to make the API thread safe,
|
||||||
|
and the internal Tcl C API doesn't support
|
||||||
|
dynamicly changing sets of subcommands.
|
||||||
|
That said, this functionality might come back, especially when
|
||||||
|
<a href="http://www.tcl.tk/cgi-bin/tct/tip/">TIP #257</a> is implemented.
|
||||||
|
Instead, in version 2,
|
||||||
|
create a Tcl function that takes the Togl widget as an argument.
|
||||||
|
Functions written in C can get the underlying Togl structure handle
|
||||||
|
with either the <code>Togl_GetToglFromObj</code>
|
||||||
|
or the <code>Togl_GetToglFromName</code> function,
|
||||||
|
as appropriate.
|
||||||
|
This means that there are no special Togl commands, only Tcl commands.
|
||||||
|
See the <a href="tclapi.html">C API</a> for details.
|
||||||
|
|
||||||
|
<h2><a name="stereo">Stereo changes</a></h2>
|
||||||
|
|
||||||
|
The stereo support has been totally revamped.
|
||||||
|
Some <a href="stereo.html">form of stereo</a> is available all of the time.
|
||||||
|
|
||||||
|
<h2><a name="fonts">Font changes</a></h2>
|
||||||
|
|
||||||
|
Tcl support for writing strings has been added.
|
||||||
|
<p>
|
||||||
|
|
||||||
|
The <a href="capi.html#font">font C API</a> has been revised
|
||||||
|
so that Togl_LoadBitmapFont returns a font object instead an integer
|
||||||
|
(likewise for Togl_UnloadBitmapFont).
|
||||||
|
So instead of calling glListBase and glCallLists directly,
|
||||||
|
use Togl_WriteObj or Togl_WriteChars.
|
||||||
|
<p>
|
||||||
|
The TOGL_BITMAP_* constants remain for limited backwards
|
||||||
|
source compatibility and are deprecated.
|
||||||
|
The acceptable font names are now the same as Tk_GetFont
|
||||||
|
and the Tk font command on all platforms.
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<a href="http://sourceforge.net/projects/togl">
|
||||||
|
<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=519&type=13" width="120" height="30" border="0" alt="Get Togl at SourceForge.net. Fast, secure and Free Open Source software downloads">
|
||||||
|
</a>
|
||||||
|
<a href="http://validator.w3.org/check?uri=referer">
|
||||||
|
<img src="http://www.w3.org/Icons/valid-html401-blue"
|
||||||
|
alt="Valid HTML 4.01 Transitional" height="31" width="88" border="0">
|
||||||
|
</a>
|
||||||
|
</body>
|
||||||
|
</html>
|
180
ng/Togl2.1/doc/using.html
Normal file
180
ng/Togl2.1/doc/using.html
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<!-- vi:set sw=2: -->
|
||||||
|
<!--
|
||||||
|
Copyright (C) 1996-2002 Brian Paul and Ben Bederson
|
||||||
|
Copyright (C) 2005-2009 Greg Couch
|
||||||
|
See the LICENSE file for copyright details.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||||
|
<title>Using the Togl Widget</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<script type="text/javascript" src="header.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
NavigationBar();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h1 align="center">Using the Togl Widget</h1>
|
||||||
|
|
||||||
|
<h2>Contents</h2>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#using">Using Togl With Your Application</a>
|
||||||
|
<li><a href="#examples">Examples</a>
|
||||||
|
<li><a href="tclapi.html">Tcl API</a>
|
||||||
|
<li><a href="capi.html">C API</a>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<h2><a name="using">Using Togl With Your Application</a></h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
First, double check that you have all of the
|
||||||
|
<a href="download.html#prereq">prerequisites</a>
|
||||||
|
and that you have
|
||||||
|
<a href="download.html#building">compiled and installed</a> Togl.
|
||||||
|
<p>
|
||||||
|
Then, Togl acts like any other extension package —
|
||||||
|
to load it, you use the Tcl <code>package</code> command:
|
||||||
|
<blockquote>
|
||||||
|
<code>package require Togl 2.0</code>
|
||||||
|
</blockquote>
|
||||||
|
After that, you can create a Togl widget just like any other Tk widget.
|
||||||
|
|
||||||
|
<h2><a name="examples">Examples</a></h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
There are eight working examples:
|
||||||
|
|
||||||
|
<blockquote>
|
||||||
|
<table border="0">
|
||||||
|
<tr>
|
||||||
|
<td>double.tcl</td>
|
||||||
|
<td>— compares single vs double buffering with two Togl widgets</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>texture.tcl</td>
|
||||||
|
<td>— lets you play with texture mapping options</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>index.tcl</td>
|
||||||
|
<td>— example of using color index mode</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>overlay.tcl</td>
|
||||||
|
<td>— example of using overlay planes (requires overlay hardware)</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>stereo.tcl</td>
|
||||||
|
<td>— stereo example</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>gears.tcl</td>
|
||||||
|
<td>— spinning gears example</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>multisample.tcl</td>
|
||||||
|
<td>— multisampling example</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>pbuffer.tcl</td>
|
||||||
|
<td>— pbuffer (off-screen rendering) example</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Each example consists of two files: a Tcl script for the user interface,
|
||||||
|
and a Tcl C package that does the OpenGL drawing.
|
||||||
|
To compile the examples, type <code>make examples</code>
|
||||||
|
in the Togl source directory.
|
||||||
|
The C packages are compiled into shared libraries
|
||||||
|
that are loaded into the Tcl interpreter as Tcl/Tk-extensions.
|
||||||
|
The examples are started by running the corrsponding Tcl script:
|
||||||
|
just type <code>./double.tcl</code>
|
||||||
|
(or <code>./texture.tcl</code> <i>etc.</i>)
|
||||||
|
or run under one of the Tcl interpreters, <i>i.e.</i>,
|
||||||
|
<code>tclsh</code> or <code>wish</code>.
|
||||||
|
For example:
|
||||||
|
<blockquote>
|
||||||
|
<code>tclsh84 double.tcl</code>
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Other examples that use Tcl for OpenGL drawing can be found in the
|
||||||
|
<a href="http://tcl3d.org/html/demos.html">Tcl3D demos</a>.
|
||||||
|
|
||||||
|
<h3><a name="callbacks">Togl callbacks</a></h3>
|
||||||
|
<p>
|
||||||
|
All of the examples have similar structure.
|
||||||
|
First they create the user interface with one or more Togl widgets.
|
||||||
|
Each Togl widget is configured with the desired pixel format
|
||||||
|
and several callback commands (not all are needed):
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><code>-createcommand</code></td>
|
||||||
|
<td>
|
||||||
|
Called when Togl widget is mapped —
|
||||||
|
when it is safe to initialize the OpenGL context.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>-reshapecommand</code></td>
|
||||||
|
<td>
|
||||||
|
Called when the Togl widget is resized —
|
||||||
|
when the OpenGL context's viewport needs to be changed.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>-displaycommand</code></td>
|
||||||
|
<td>
|
||||||
|
Called when the contents of the Togl widget needs to be redrawn.
|
||||||
|
Redraws are normally delayed to be when the Tcl event loop is idle
|
||||||
|
(see the togl widget's <code>postredisplay</code> command),
|
||||||
|
or as the result of an explict call to the togl's widgets
|
||||||
|
<code>render</code> command.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>-destroycommand</code></td>
|
||||||
|
<td>
|
||||||
|
Called when the Togl widget is destroyed.
|
||||||
|
While OpenGL frees display lists and other resources,
|
||||||
|
sometimes there's some associated state that is no longer needed.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>-timercommand</code></td>
|
||||||
|
<td>
|
||||||
|
Called every <i>n</i> milliseconds
|
||||||
|
as given by the <code>-time</code> option.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>-overlaydisplaycommand</code></td>
|
||||||
|
<td>
|
||||||
|
Called when the overlay planes needs to be redrawn.
|
||||||
|
The overlay planes are created and reshaped
|
||||||
|
at the same time as the main OpenGL context.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
Typically, only <code>-createcommand</code>, <code>-reshapecommand</code>
|
||||||
|
and <code>-displaycommand</code> are used.
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<a href="http://sourceforge.net/projects/togl">
|
||||||
|
<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=519&type=13" width="120" height="30" border="0" alt="Get Togl at SourceForge.net. Fast, secure and Free Open Source software downloads">
|
||||||
|
</a>
|
||||||
|
<a href="http://validator.w3.org/check?uri=referer">
|
||||||
|
<img src="http://www.w3.org/Icons/valid-html401-blue"
|
||||||
|
alt="Valid HTML 4.01 Transitional" height="31" width="88" border="0">
|
||||||
|
</a>
|
||||||
|
</body>
|
||||||
|
</html>
|
279
ng/Togl2.1/double.c
Normal file
279
ng/Togl2.1/double.c
Normal file
@ -0,0 +1,279 @@
|
|||||||
|
/* $Id: double.c,v 1.22 2009/03/12 23:59:35 gregcouch Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl - a Tk OpenGL widget
|
||||||
|
* Copyright (C) 1996-1997 Brian Paul and Ben Bederson
|
||||||
|
* Copyright (C) 2006-2007 Greg Couch
|
||||||
|
* See the LICENSE file for copyright details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define USE_TOGL_STUBS
|
||||||
|
|
||||||
|
#include "togl.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#undef TCL_STORAGE_CLASS
|
||||||
|
#define TCL_STORAGE_CLASS DLLEXPORT
|
||||||
|
|
||||||
|
static Tcl_Obj *toglFont;
|
||||||
|
static double xAngle = 0, yAngle = 0, zAngle = 0;
|
||||||
|
static GLdouble CornerX, CornerY, CornerZ; /* where to print strings */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl widget create callback. This is called by Tcl/Tk when the widget has
|
||||||
|
* been realized. Here's where one may do some one-time context setup or
|
||||||
|
* initializations.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
create_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!toglFont)
|
||||||
|
toglFont = Togl_LoadBitmapFont(togl, "Helvetica");
|
||||||
|
if (!toglFont) {
|
||||||
|
static int shown;
|
||||||
|
|
||||||
|
if (!shown) {
|
||||||
|
fprintf(stderr, "Couldn't load font!\n");
|
||||||
|
shown = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl widget reshape callback. This is called by Tcl/Tk when the widget
|
||||||
|
* has been resized. Typically, we call glViewport and perhaps setup the
|
||||||
|
* projection matrix.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
reshape_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
double aspect;
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
width = Togl_Width(togl);
|
||||||
|
height = Togl_Height(togl);
|
||||||
|
aspect = (double) width / (double) height;
|
||||||
|
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
|
||||||
|
/* Set up projection transform */
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glFrustum(-aspect, aspect, -1, 1, 1, 10);
|
||||||
|
|
||||||
|
CornerX = -aspect;
|
||||||
|
CornerY = -1;
|
||||||
|
CornerZ = -1.1;
|
||||||
|
|
||||||
|
/* Change back to model view transform for rendering */
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_string(Togl *togl, const char *s)
|
||||||
|
{
|
||||||
|
if (toglFont)
|
||||||
|
Togl_WriteChars(togl, toglFont, s, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl widget display callback. This is called by Tcl/Tk when the widget's
|
||||||
|
* contents have to be redrawn. Typically, we clear the color and depth
|
||||||
|
* buffers, render our objects, then swap the front/back color buffers.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
display_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
static GLuint cubeList = 0;
|
||||||
|
const char *ident;
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK)
|
||||||
|
return TCL_ERROR;
|
||||||
|
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
glLoadIdentity(); /* Reset modelview matrix to the identity
|
||||||
|
* matrix */
|
||||||
|
glTranslatef(0, 0, -3); /* Move the camera back three units */
|
||||||
|
glRotated(xAngle, 1, 0, 0); /* Rotate by X, Y, and Z angles */
|
||||||
|
glRotated(yAngle, 0, 1, 0);
|
||||||
|
glRotated(zAngle, 0, 0, 1);
|
||||||
|
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
if (!cubeList) {
|
||||||
|
cubeList = glGenLists(1);
|
||||||
|
glNewList(cubeList, GL_COMPILE);
|
||||||
|
|
||||||
|
/* Front face */
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glColor3f(0, 0.7f, 0.1f); /* Green */
|
||||||
|
glVertex3f(-1, 1, 1);
|
||||||
|
glVertex3f(1, 1, 1);
|
||||||
|
glVertex3f(1, -1, 1);
|
||||||
|
glVertex3f(-1, -1, 1);
|
||||||
|
/* Back face */
|
||||||
|
glColor3f(0.9f, 1, 0); /* Yellow */
|
||||||
|
glVertex3f(-1, 1, -1);
|
||||||
|
glVertex3f(1, 1, -1);
|
||||||
|
glVertex3f(1, -1, -1);
|
||||||
|
glVertex3f(-1, -1, -1);
|
||||||
|
/* Top side face */
|
||||||
|
glColor3f(0.2f, 0.2f, 1); /* Blue */
|
||||||
|
glVertex3f(-1, 1, 1);
|
||||||
|
glVertex3f(1, 1, 1);
|
||||||
|
glVertex3f(1, 1, -1);
|
||||||
|
glVertex3f(-1, 1, -1);
|
||||||
|
/* Bottom side face */
|
||||||
|
glColor3f(0.7f, 0, 0.1f); /* Red */
|
||||||
|
glVertex3f(-1, -1, 1);
|
||||||
|
glVertex3f(1, -1, 1);
|
||||||
|
glVertex3f(1, -1, -1);
|
||||||
|
glVertex3f(-1, -1, -1);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glEndList();
|
||||||
|
|
||||||
|
}
|
||||||
|
glCallList(cubeList);
|
||||||
|
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
glLoadIdentity();
|
||||||
|
glColor3f(1, 1, 1);
|
||||||
|
glRasterPos3d(CornerX, CornerY, CornerZ);
|
||||||
|
ident = Togl_Ident(togl);
|
||||||
|
if (ident)
|
||||||
|
print_string(togl, ident);
|
||||||
|
Togl_SwapBuffers(togl);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
setXrot_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "angle");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Tcl_GetDoubleFromObj(interp, objv[1], &xAngle) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* printf( "before %f ", xAngle ); */
|
||||||
|
|
||||||
|
xAngle = fmod(xAngle, 360.0);
|
||||||
|
if (xAngle < 0)
|
||||||
|
xAngle += 360.0;
|
||||||
|
|
||||||
|
/* printf( "after %f \n", xAngle ); */
|
||||||
|
|
||||||
|
/* Let result string equal value */
|
||||||
|
Tcl_SetObjResult(interp, objv[1]);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
setYrot_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName angle");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Tcl_GetDoubleFromObj(interp, objv[1], &yAngle) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
yAngle = fmod(yAngle, 360.0);
|
||||||
|
if (yAngle < 0)
|
||||||
|
yAngle += 360.0;
|
||||||
|
|
||||||
|
/* Let result string equal value */
|
||||||
|
Tcl_SetObjResult(interp, objv[1]);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called by Tcl to let me initialize the modules (Togl) I will need.
|
||||||
|
*/
|
||||||
|
EXTERN int
|
||||||
|
Double_Init(Tcl_Interp *interp)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Initialize Tcl and the Togl widget module.
|
||||||
|
*/
|
||||||
|
if (Tcl_InitStubs(interp, "8.1", 0) == NULL
|
||||||
|
|| Togl_InitStubs(interp, "2.0", 0) == NULL) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Specify the C callback functions for widget creation, display,
|
||||||
|
* and reshape.
|
||||||
|
*/
|
||||||
|
Tcl_CreateObjCommand(interp, "double::create_cb", create_cb, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "double::display_cb", display_cb, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "double::reshape_cb", reshape_cb, NULL, NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make a new Togl widget command so the Tcl code can set a C variable.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Tcl_CreateObjCommand(interp, "double::setXrot", setXrot_cb, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "double::setYrot", setYrot_cb, NULL, NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Call Tcl_CreateCommand for application-specific commands, if
|
||||||
|
* they weren't already created by the init procedures called above.
|
||||||
|
*/
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
96
ng/Togl2.1/double.tcl
Normal file
96
ng/Togl2.1/double.tcl
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# the next line restarts using tclsh \
|
||||||
|
exec tclsh "$0" "$@"
|
||||||
|
|
||||||
|
# $Id: double.tcl,v 1.11 2009/03/12 23:59:35 gregcouch Exp $
|
||||||
|
|
||||||
|
# Togl - a Tk OpenGL widget
|
||||||
|
# Copyright (C) 1996 Brian Paul and Ben Bederson
|
||||||
|
# Copyright (C) 2006-2007 Greg Couch
|
||||||
|
# See the LICENSE file for copyright details.
|
||||||
|
|
||||||
|
|
||||||
|
# An Tk/OpenGL widget demo with two windows, one single buffered and the
|
||||||
|
# other double buffered.
|
||||||
|
|
||||||
|
package provide double 1.0
|
||||||
|
|
||||||
|
# add parent directory to path to find Togl's pkgIndex in current directory
|
||||||
|
if { [file exists pkgIndex.tcl] } {
|
||||||
|
set auto_path [linsert $auto_path 0 ..]
|
||||||
|
}
|
||||||
|
# following load also loads Tk and Togl packages
|
||||||
|
load [file dirname [info script]]/double[info sharedlibextension]
|
||||||
|
|
||||||
|
# create ::double namespace
|
||||||
|
namespace eval ::double {
|
||||||
|
}
|
||||||
|
|
||||||
|
proc double::setup {} {
|
||||||
|
wm title . "Single vs Double Buffering"
|
||||||
|
|
||||||
|
# create first Togl widget
|
||||||
|
togl .o1 -width 200 -height 200 -rgba true -double false -depth true -ident "Single Buffered" -create double::create_cb -display double::display_cb -reshape double::reshape_cb
|
||||||
|
|
||||||
|
# create second Togl widget, share display lists with first widget
|
||||||
|
togl .o2 -width 200 -height 200 -rgba true -double true -depth true -ident "Double Buffered" -sharelist "Single Buffered" -create double::create_cb -display double::display_cb -reshape double::reshape_cb
|
||||||
|
|
||||||
|
scale .sx -label {X Axis} -from 0 -to 360 -command {::double::setAngle x} -orient horizontal
|
||||||
|
scale .sy -label {Y Axis} -from 0 -to 360 -command {::double::setAngle y} -orient horizontal
|
||||||
|
button .btn -text Quit -command exit
|
||||||
|
|
||||||
|
bind .o1 <B1-Motion> {
|
||||||
|
::double::motion_event [lindex [%W config -width] 4] \
|
||||||
|
[lindex [%W config -height] 4] \
|
||||||
|
%x %y
|
||||||
|
}
|
||||||
|
|
||||||
|
bind .o2 <B1-Motion> {
|
||||||
|
::double::motion_event [lindex [%W config -width] 4] \
|
||||||
|
[lindex [%W config -height] 4] \
|
||||||
|
%x %y
|
||||||
|
}
|
||||||
|
|
||||||
|
grid rowconfigure . 0 -weight 1
|
||||||
|
grid columnconfigure . 0 -weight 1 -uniform same
|
||||||
|
grid columnconfigure . 1 -weight 1 -uniform same
|
||||||
|
grid .o1 -row 0 -column 0 -sticky nesw -padx 3 -pady 3
|
||||||
|
grid .o2 -row 0 -column 1 -sticky nesw -padx 3 -pady 3
|
||||||
|
#grid .l1 -row 1 -column 0 -sticky ew -padx 3 -pady 3
|
||||||
|
#grid .l2 -row 1 -column 1 -sticky ew -padx 3 -pady 3
|
||||||
|
grid .sx -row 2 -column 0 -columnspan 2 -sticky ew
|
||||||
|
grid .sy -row 3 -column 0 -columnspan 2 -sticky ew
|
||||||
|
grid .btn -row 4 -column 0 -columnspan 2 -sticky ew
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# This is called when mouse button 1 is pressed and moved in either of
|
||||||
|
# the OpenGL windows.
|
||||||
|
proc double::motion_event { width height x y } {
|
||||||
|
.sx set [double::setXrot [expr 360.0 * $y / $height]]
|
||||||
|
.sy set [double::setYrot [expr 360.0 * ($width - $x) / $width]]
|
||||||
|
|
||||||
|
.o1 postredisplay
|
||||||
|
.o2 postredisplay
|
||||||
|
}
|
||||||
|
|
||||||
|
# This is called when a slider is changed.
|
||||||
|
proc double::setAngle {axis value} {
|
||||||
|
global xAngle yAngle zAngle
|
||||||
|
|
||||||
|
switch -exact $axis {
|
||||||
|
x {double::setXrot $value
|
||||||
|
double::setXrot $value}
|
||||||
|
y {double::setYrot $value
|
||||||
|
double::setYrot $value}
|
||||||
|
}
|
||||||
|
|
||||||
|
.o1 postredisplay
|
||||||
|
.o2 postredisplay
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execution starts here!
|
||||||
|
if { [info script] == $argv0 } {
|
||||||
|
::double::setup
|
||||||
|
}
|
491
ng/Togl2.1/gears.c
Normal file
491
ng/Togl2.1/gears.c
Normal file
@ -0,0 +1,491 @@
|
|||||||
|
/* gears.c */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 3-D gear wheels. This program is in the public domain.
|
||||||
|
*
|
||||||
|
* Brian Paul
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Modified to work under Togl as a widget for TK 1997
|
||||||
|
*
|
||||||
|
* Philip Quaife
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define USE_TOGL_STUBS
|
||||||
|
|
||||||
|
#include "togl.h"
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#undef TCL_STORAGE_CLASS
|
||||||
|
#define TCL_STORAGE_CLASS DLLEXPORT
|
||||||
|
|
||||||
|
#ifndef M_PI
|
||||||
|
# define M_PI 3.14159265
|
||||||
|
#endif
|
||||||
|
#define FM_PI ((float) M_PI)
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
__inline float
|
||||||
|
sinf(double a)
|
||||||
|
{
|
||||||
|
return (float) sin(a);
|
||||||
|
}
|
||||||
|
__inline float
|
||||||
|
cosf(double a)
|
||||||
|
{
|
||||||
|
return (float) cos(a);
|
||||||
|
}
|
||||||
|
__inline float
|
||||||
|
sqrtf(double a)
|
||||||
|
{
|
||||||
|
return (float) sqrt(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
# define sin sinf
|
||||||
|
# define cos cosf
|
||||||
|
# define sqrt sqrtf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct WHIRLYGIZMO
|
||||||
|
{
|
||||||
|
int Gear1, Gear2, Gear3;
|
||||||
|
double Rotx, Roty, Rotz;
|
||||||
|
double Angle;
|
||||||
|
int Height, Width;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct WHIRLYGIZMO WHIRLYGIZMO;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Draw a gear wheel. You'll probably want to call this function when
|
||||||
|
* building a display list since we do a lot of trig here.
|
||||||
|
*
|
||||||
|
* Input: inner_radius - radius of hole at center
|
||||||
|
* outer_radius - radius at center of teeth
|
||||||
|
* width - width of gear
|
||||||
|
* teeth - number of teeth
|
||||||
|
* tooth_depth - depth of tooth
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
|
||||||
|
GLint teeth, GLfloat tooth_depth)
|
||||||
|
{
|
||||||
|
GLint i;
|
||||||
|
GLfloat r0, r1, r2;
|
||||||
|
GLfloat angle, da;
|
||||||
|
GLfloat u, v, len;
|
||||||
|
|
||||||
|
r0 = inner_radius;
|
||||||
|
r1 = outer_radius - tooth_depth / 2;
|
||||||
|
r2 = outer_radius + tooth_depth / 2;
|
||||||
|
|
||||||
|
da = 2 * FM_PI / teeth / 4;
|
||||||
|
|
||||||
|
glShadeModel(GL_FLAT);
|
||||||
|
|
||||||
|
glNormal3f(0, 0, 1);
|
||||||
|
|
||||||
|
/* draw front face */
|
||||||
|
glBegin(GL_QUAD_STRIP);
|
||||||
|
for (i = 0; i <= teeth; i++) {
|
||||||
|
angle = i * 2 * FM_PI / teeth;
|
||||||
|
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5f);
|
||||||
|
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5f);
|
||||||
|
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5f);
|
||||||
|
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||||
|
width * 0.5f);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
/* draw front sides of teeth */
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
da = 2 * FM_PI / teeth / 4;
|
||||||
|
for (i = 0; i < teeth; i++) {
|
||||||
|
angle = i * 2 * FM_PI / teeth;
|
||||||
|
|
||||||
|
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5f);
|
||||||
|
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5f);
|
||||||
|
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||||
|
width * 0.5f);
|
||||||
|
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||||
|
width * 0.5f);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
|
||||||
|
glNormal3f(0, 0, -1);
|
||||||
|
|
||||||
|
/* draw back face */
|
||||||
|
glBegin(GL_QUAD_STRIP);
|
||||||
|
for (i = 0; i <= teeth; i++) {
|
||||||
|
angle = i * 2 * FM_PI / teeth;
|
||||||
|
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5f);
|
||||||
|
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5f);
|
||||||
|
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||||
|
-width * 0.5f);
|
||||||
|
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5f);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
/* draw back sides of teeth */
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
da = 2 * FM_PI / teeth / 4;
|
||||||
|
for (i = 0; i < teeth; i++) {
|
||||||
|
angle = i * 2 * FM_PI / teeth;
|
||||||
|
|
||||||
|
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||||
|
-width * 0.5f);
|
||||||
|
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||||
|
-width * 0.5f);
|
||||||
|
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5f);
|
||||||
|
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5f);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
|
||||||
|
/* draw outward faces of teeth */
|
||||||
|
glBegin(GL_QUAD_STRIP);
|
||||||
|
for (i = 0; i < teeth; i++) {
|
||||||
|
angle = i * 2 * FM_PI / teeth;
|
||||||
|
|
||||||
|
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5f);
|
||||||
|
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5f);
|
||||||
|
u = r2 * cos(angle + da) - r1 * cos(angle);
|
||||||
|
v = r2 * sin(angle + da) - r1 * sin(angle);
|
||||||
|
len = sqrt(u * u + v * v);
|
||||||
|
u /= len;
|
||||||
|
v /= len;
|
||||||
|
glNormal3f(v, -u, 0);
|
||||||
|
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5f);
|
||||||
|
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5f);
|
||||||
|
glNormal3f(cos(angle), sin(angle), 0);
|
||||||
|
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||||
|
width * 0.5f);
|
||||||
|
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||||
|
-width * 0.5f);
|
||||||
|
u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da);
|
||||||
|
v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da);
|
||||||
|
glNormal3f(v, -u, 0);
|
||||||
|
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||||
|
width * 0.5f);
|
||||||
|
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||||
|
-width * 0.5f);
|
||||||
|
glNormal3f(cos(angle), sin(angle), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
glVertex3f(r1 /* * cos(0) */ , /* r1 * sin(0) */ 0, width * 0.5f);
|
||||||
|
glVertex3f(r1 /* * cos(0) */ , /* r1 * sin(0) */ 0, -width * 0.5f);
|
||||||
|
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
|
||||||
|
glShadeModel(GL_SMOOTH);
|
||||||
|
|
||||||
|
/* draw inside radius cylinder */
|
||||||
|
glBegin(GL_QUAD_STRIP);
|
||||||
|
for (i = 0; i <= teeth; i++) {
|
||||||
|
angle = i * 2 * FM_PI / teeth;
|
||||||
|
glNormal3f(-cos(angle), -sin(angle), 0);
|
||||||
|
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5f);
|
||||||
|
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5f);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* static GLfloat view_rotx=20, view_roty=30, view_rotz=0; static GLint
|
||||||
|
* gear1, gear2, gear3; static GLfloat angle = 0; */
|
||||||
|
static GLuint limit;
|
||||||
|
static GLuint count = 1;
|
||||||
|
|
||||||
|
static GLubyte polycolor[4] = { 255, 255, 255, 255 };
|
||||||
|
|
||||||
|
static int
|
||||||
|
draw(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
WHIRLYGIZMO *Wg;
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
Wg = (WHIRLYGIZMO *) Togl_GetClientData(togl);
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
glPushMatrix();
|
||||||
|
glRotatef((float) Wg->Rotx, 1, 0, 0);
|
||||||
|
glRotatef((float) Wg->Roty, 0, 1, 0);
|
||||||
|
glRotatef((float) Wg->Rotz, 0, 0, 1);
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(-3, -2, 0);
|
||||||
|
glRotatef((float) Wg->Angle, 0, 0, 1);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glCallList(Wg->Gear1);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(3.1f, -2, 0);
|
||||||
|
glRotatef(-2 * (float) Wg->Angle - 9, 0, 0, 1);
|
||||||
|
glCallList(Wg->Gear2);
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(-3.1f, 4.2f, 0);
|
||||||
|
glRotatef(-2 * (float) Wg->Angle - 25, 0, 0, 1);
|
||||||
|
glCallList(Wg->Gear3);
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
Togl_SwapBuffers(togl);
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
zap(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
WHIRLYGIZMO *Wg;
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
Wg = (WHIRLYGIZMO *) Togl_GetClientData(togl);
|
||||||
|
free(Wg);
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
idle(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
WHIRLYGIZMO *Wg;
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
Wg = (WHIRLYGIZMO *) Togl_GetClientData(togl);
|
||||||
|
Wg->Angle += 2;
|
||||||
|
Togl_PostRedisplay(togl);
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* change view angle, exit upon ESC */
|
||||||
|
/*
|
||||||
|
* static GLenum key(int k, GLenum mask) { switch (k) { case TK_UP: view_rotx
|
||||||
|
* += 5; return GL_TRUE; case TK_DOWN: view_rotx -= 5; return GL_TRUE; case
|
||||||
|
* TK_LEFT: view_roty += 5; return GL_TRUE; case TK_RIGHT: view_roty -= 5;
|
||||||
|
* return GL_TRUE; case TK_z: view_rotz += 5; return GL_TRUE; case TK_Z:
|
||||||
|
* view_rotz -= 5; return GL_TRUE; } return GL_FALSE; } */
|
||||||
|
|
||||||
|
/* new window size or exposure */
|
||||||
|
static int
|
||||||
|
reshape(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
int width, height;
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
width = Togl_Width(togl);
|
||||||
|
height = Togl_Height(togl);
|
||||||
|
glViewport(0, 0, (GLint) width, (GLint) height);
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
if (width > height) {
|
||||||
|
GLfloat w = (GLfloat) width / (GLfloat) height;
|
||||||
|
|
||||||
|
glFrustum(-w, w, -1, 1, 5, 60);
|
||||||
|
} else {
|
||||||
|
GLfloat h = (GLfloat) height / (GLfloat) width;
|
||||||
|
|
||||||
|
glFrustum(-1, 1, -h, h, 5, 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
glTranslatef(0, 0, -40);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
init(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
WHIRLYGIZMO *Wg;
|
||||||
|
static GLfloat red[4] = { 0.8f, 0.1f, 0, 1 };
|
||||||
|
static GLfloat green[4] = { 0, 0.8f, 0.2f, 1 };
|
||||||
|
static GLfloat blue[4] = { 0.2f, 0.2f, 1, 1 };
|
||||||
|
static GLfloat pos[4] = { 5, 5, 10, 0 };
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
glLightfv(GL_LIGHT0, GL_POSITION, pos);
|
||||||
|
glEnable(GL_CULL_FACE);
|
||||||
|
glEnable(GL_LIGHTING);
|
||||||
|
glEnable(GL_LIGHT0);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
/* make the gears */
|
||||||
|
Wg = (WHIRLYGIZMO *) malloc(sizeof (WHIRLYGIZMO));
|
||||||
|
if (!Wg) {
|
||||||
|
Tcl_SetResult(Togl_Interp(togl),
|
||||||
|
"\"Cannot allocate client data for widget\"", TCL_STATIC);
|
||||||
|
}
|
||||||
|
Wg->Gear1 = glGenLists(1);
|
||||||
|
glNewList(Wg->Gear1, GL_COMPILE);
|
||||||
|
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
|
||||||
|
gear(1, 4, 1, 20, 0.7f);
|
||||||
|
glEndList();
|
||||||
|
|
||||||
|
Wg->Gear2 = glGenLists(1);
|
||||||
|
glNewList(Wg->Gear2, GL_COMPILE);
|
||||||
|
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
|
||||||
|
gear(0.5f, 2, 2, 10, 0.7f);
|
||||||
|
glEndList();
|
||||||
|
|
||||||
|
Wg->Gear3 = glGenLists(1);
|
||||||
|
glNewList(Wg->Gear3, GL_COMPILE);
|
||||||
|
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
|
||||||
|
gear(1.3f, 2, 0.5f, 10, 0.7f);
|
||||||
|
glEndList();
|
||||||
|
|
||||||
|
glEnable(GL_NORMALIZE);
|
||||||
|
Wg->Height = Togl_Height(togl);
|
||||||
|
Wg->Width = Togl_Width(togl);
|
||||||
|
Wg->Angle = 0;
|
||||||
|
Wg->Rotx = 0;
|
||||||
|
Wg->Roty = 0;
|
||||||
|
Wg->Rotz = 0;
|
||||||
|
Togl_SetClientData(togl, (ClientData) Wg);
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
position(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
WHIRLYGIZMO *Wg;
|
||||||
|
char Result[100];
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
Wg = (WHIRLYGIZMO *) Togl_GetClientData(togl);
|
||||||
|
|
||||||
|
/* Let result string equal value */
|
||||||
|
sprintf(Result, "%g %g", Wg->Roty, Wg->Rotx);
|
||||||
|
|
||||||
|
Tcl_SetResult(interp, Result, TCL_VOLATILE);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
rotate(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
WHIRLYGIZMO *Wg;
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 4) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName yrot xrot");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
Wg = (WHIRLYGIZMO *) Togl_GetClientData(togl);
|
||||||
|
|
||||||
|
if (Tcl_GetDoubleFromObj(interp, objv[2], &Wg->Roty) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
if (Tcl_GetDoubleFromObj(interp, objv[3], &Wg->Rotx) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
Togl_PostRedisplay(togl);
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
EXTERN int
|
||||||
|
Gears_Init(Tcl_Interp *interp)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Initialize Tcl and the Togl widget module.
|
||||||
|
*/
|
||||||
|
if (Tcl_InitStubs(interp, "8.1", 0) == NULL
|
||||||
|
|| Togl_InitStubs(interp, "2.0", 0) == NULL) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Specify the C callback functions for widget creation, display,
|
||||||
|
* and reshape.
|
||||||
|
*/
|
||||||
|
Tcl_CreateObjCommand(interp, "init", init, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "zap", zap, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "draw", draw, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "reshape", reshape, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "idle", idle, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "rotate", rotate, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "position", position, NULL, NULL);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
90
ng/Togl2.1/gears.tcl
Normal file
90
ng/Togl2.1/gears.tcl
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# the next line restarts using tclsh \
|
||||||
|
exec tclsh "$0" "$@"
|
||||||
|
|
||||||
|
# Togl - a Tk OpenGL widget
|
||||||
|
# Copyright (C) 1996-1997 Brian Paul and Ben Bederson
|
||||||
|
# Copyright (C) 2006-2007 Greg Couch
|
||||||
|
# See the LICENSE file for copyright details.
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test Togl using GL Gears Demo
|
||||||
|
#
|
||||||
|
# Copyright (C) 1997 Philip Quaife
|
||||||
|
#
|
||||||
|
|
||||||
|
package provide gears 1.0
|
||||||
|
|
||||||
|
# add parent directory to path to find Togl's pkgIndex in current directory
|
||||||
|
if { [file exists pkgIndex.tcl] } {
|
||||||
|
set auto_path [linsert $auto_path 0 ..]
|
||||||
|
}
|
||||||
|
# following load also loads Tk and Togl packages
|
||||||
|
load [file dirname [info script]]/gears[info sharedlibextension]
|
||||||
|
|
||||||
|
# create ::gears namespace
|
||||||
|
namespace eval ::gears {
|
||||||
|
}
|
||||||
|
|
||||||
|
proc ::gears::setup {} {
|
||||||
|
global startx starty xangle0 yangle0 xangle yangle RotCnt
|
||||||
|
global vTime
|
||||||
|
set RotCnt 1
|
||||||
|
set xangle 0.0
|
||||||
|
set yangle 0.0
|
||||||
|
set vTime 100
|
||||||
|
wm title . "Rotating Gear Widget Test"
|
||||||
|
|
||||||
|
label .t -text "Click and drag to rotate image"
|
||||||
|
pack .t -side top -padx 2 -pady 10
|
||||||
|
frame .f
|
||||||
|
pack .f -side top
|
||||||
|
button .f.n1 -text " Add " -command ::gears::AutoRot
|
||||||
|
button .f.r1 -text "Remove" -command ::gears::DelRot
|
||||||
|
button .f.b1 -text " Quit " -command exit
|
||||||
|
entry .f.t -width 4 -textvariable vTime
|
||||||
|
pack .f.n1 .f.t .f.r1 .f.b1 -side left -anchor w -padx 5
|
||||||
|
newRot .w0 10
|
||||||
|
|
||||||
|
}
|
||||||
|
proc ::gears::AutoRot {} {
|
||||||
|
global RotCnt vTime
|
||||||
|
newRot .w$RotCnt $vTime
|
||||||
|
set RotCnt [expr $RotCnt + 1]
|
||||||
|
}
|
||||||
|
|
||||||
|
proc ::gears::DelRot {} {
|
||||||
|
global RotCnt vTime
|
||||||
|
if { $RotCnt != 0 } {
|
||||||
|
set RotCnt [expr $RotCnt - 1]
|
||||||
|
destroy .w$RotCnt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
proc ::gears::newRot {win {tick 100} } {
|
||||||
|
togl $win -width 200 -height 200 -rgba true -double true -depth true -privatecmap false -time $tick -create init -destroy zap -display draw -reshape reshape -timer idle
|
||||||
|
bind $win <ButtonPress-1> {::gears::RotStart %x %y %W}
|
||||||
|
bind $win <B1-Motion> {::gears::RotMove %x %y %W}
|
||||||
|
pack $win -expand true -fill both
|
||||||
|
}
|
||||||
|
|
||||||
|
proc ::gears::RotStart {x y W} {
|
||||||
|
global startx starty xangle0 yangle0 xangle yangle
|
||||||
|
set startx $x
|
||||||
|
set starty $y
|
||||||
|
set vPos [position $W]
|
||||||
|
set xangle0 [lindex $vPos 0]
|
||||||
|
set yangle0 [lindex $vPos 1]
|
||||||
|
}
|
||||||
|
|
||||||
|
proc ::gears::RotMove {x y W} {
|
||||||
|
global startx starty xangle0 yangle0 xangle yangle
|
||||||
|
set xangle [expr $xangle0 + ($x - $startx)]
|
||||||
|
set yangle [expr $yangle0 + ($y - $starty)]
|
||||||
|
rotate $W $xangle $yangle
|
||||||
|
}
|
||||||
|
|
||||||
|
if { [info script] == $argv0 } {
|
||||||
|
::gears::setup
|
||||||
|
}
|
249
ng/Togl2.1/image.c
Normal file
249
ng/Togl2.1/image.c
Normal file
@ -0,0 +1,249 @@
|
|||||||
|
/*
|
||||||
|
* SGI rgb file reader borrowed from gltk library
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "togl.h" /* added by GG to include windows.h */
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "image.h"
|
||||||
|
|
||||||
|
#ifndef SEEK_SET
|
||||||
|
# define SEEK_SET 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
tkQuit(void)
|
||||||
|
{
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
typedef struct _rawImageRec
|
||||||
|
{
|
||||||
|
unsigned short imagic;
|
||||||
|
unsigned short type;
|
||||||
|
unsigned short dim;
|
||||||
|
unsigned short sizeX, sizeY, sizeZ;
|
||||||
|
unsigned long min, max;
|
||||||
|
unsigned long wasteBytes;
|
||||||
|
char name[80];
|
||||||
|
unsigned long colorMap;
|
||||||
|
FILE *file;
|
||||||
|
unsigned char *tmp, *tmpR, *tmpG, *tmpB, *tmpA;
|
||||||
|
unsigned long rleEnd;
|
||||||
|
GLuint *rowStart;
|
||||||
|
GLint *rowSize;
|
||||||
|
} rawImageRec;
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
static void
|
||||||
|
ConvertShort(unsigned short *array, long length)
|
||||||
|
{
|
||||||
|
unsigned long b1, b2;
|
||||||
|
unsigned char *ptr;
|
||||||
|
|
||||||
|
ptr = (unsigned char *) array;
|
||||||
|
while (length--) {
|
||||||
|
b1 = *ptr++;
|
||||||
|
b2 = *ptr++;
|
||||||
|
*array++ = (unsigned short) ((b1 << 8) | b2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ConvertLong(GLuint *array, long length)
|
||||||
|
{
|
||||||
|
unsigned long b1, b2, b3, b4;
|
||||||
|
unsigned char *ptr;
|
||||||
|
|
||||||
|
ptr = (unsigned char *) array;
|
||||||
|
while (length--) {
|
||||||
|
b1 = *ptr++;
|
||||||
|
b2 = *ptr++;
|
||||||
|
b3 = *ptr++;
|
||||||
|
b4 = *ptr++;
|
||||||
|
*array++ = (b1 << 24) | (b2 << 16) | (b3 << 8) | (b4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static rawImageRec *
|
||||||
|
RawImageOpen(const char *fileName)
|
||||||
|
{
|
||||||
|
union
|
||||||
|
{
|
||||||
|
int testWord;
|
||||||
|
char testByte[4];
|
||||||
|
} endianTest;
|
||||||
|
rawImageRec *raw;
|
||||||
|
GLenum swapFlag;
|
||||||
|
int x;
|
||||||
|
|
||||||
|
endianTest.testWord = 1;
|
||||||
|
if (endianTest.testByte[0] == 1) {
|
||||||
|
swapFlag = GL_TRUE;
|
||||||
|
} else {
|
||||||
|
swapFlag = GL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
raw = (rawImageRec *) malloc(sizeof (rawImageRec));
|
||||||
|
if (raw == NULL) {
|
||||||
|
fprintf(stderr, "Out of memory!\n");
|
||||||
|
tkQuit();
|
||||||
|
}
|
||||||
|
if ((raw->file = fopen(fileName, "rb")) == NULL) {
|
||||||
|
perror(fileName);
|
||||||
|
tkQuit();
|
||||||
|
}
|
||||||
|
|
||||||
|
fread(raw, 1, 12, raw->file);
|
||||||
|
|
||||||
|
if (swapFlag) {
|
||||||
|
ConvertShort(&raw->imagic, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
raw->tmp = (unsigned char *) malloc(raw->sizeX * 256);
|
||||||
|
raw->tmpR = (unsigned char *) malloc(raw->sizeX * 256);
|
||||||
|
raw->tmpG = (unsigned char *) malloc(raw->sizeX * 256);
|
||||||
|
raw->tmpB = (unsigned char *) malloc(raw->sizeX * 256);
|
||||||
|
raw->tmpA = (unsigned char *) malloc(raw->sizeX * 256);
|
||||||
|
if (raw->tmp == NULL || raw->tmpR == NULL || raw->tmpG == NULL ||
|
||||||
|
raw->tmpB == NULL || raw->tmpA == NULL) {
|
||||||
|
fprintf(stderr, "Out of memory!\n");
|
||||||
|
tkQuit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((raw->type & 0xFF00) == 0x0100) {
|
||||||
|
x = raw->sizeY * raw->sizeZ * sizeof (GLuint);
|
||||||
|
raw->rowStart = (GLuint *) malloc(x);
|
||||||
|
raw->rowSize = (GLint *) malloc(x);
|
||||||
|
if (raw->rowStart == NULL || raw->rowSize == NULL) {
|
||||||
|
fprintf(stderr, "Out of memory!\n");
|
||||||
|
tkQuit();
|
||||||
|
}
|
||||||
|
raw->rleEnd = 512 + (2 * x);
|
||||||
|
fseek(raw->file, 512, SEEK_SET);
|
||||||
|
fread(raw->rowStart, 1, x, raw->file);
|
||||||
|
fread(raw->rowSize, 1, x, raw->file);
|
||||||
|
if (swapFlag) {
|
||||||
|
ConvertLong(raw->rowStart, x / sizeof (GLuint));
|
||||||
|
ConvertLong((GLuint *) raw->rowSize, x / sizeof (GLint));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return raw;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
RawImageClose(rawImageRec * raw)
|
||||||
|
{
|
||||||
|
|
||||||
|
fclose(raw->file);
|
||||||
|
free(raw->tmp);
|
||||||
|
free(raw->tmpR);
|
||||||
|
free(raw->tmpG);
|
||||||
|
free(raw->tmpB);
|
||||||
|
free(raw->tmpA);
|
||||||
|
free(raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
RawImageGetRow(rawImageRec * raw, unsigned char *buf, int y, int z)
|
||||||
|
{
|
||||||
|
unsigned char *iPtr, *oPtr, pixel;
|
||||||
|
int count;
|
||||||
|
|
||||||
|
if ((raw->type & 0xFF00) == 0x0100) {
|
||||||
|
fseek(raw->file, raw->rowStart[y + z * raw->sizeY], SEEK_SET);
|
||||||
|
fread(raw->tmp, 1, (unsigned int) raw->rowSize[y + z * raw->sizeY],
|
||||||
|
raw->file);
|
||||||
|
|
||||||
|
iPtr = raw->tmp;
|
||||||
|
oPtr = buf;
|
||||||
|
while (1) {
|
||||||
|
pixel = *iPtr++;
|
||||||
|
count = (int) (pixel & 0x7F);
|
||||||
|
if (!count) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pixel & 0x80) {
|
||||||
|
while (count--) {
|
||||||
|
*oPtr++ = *iPtr++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pixel = *iPtr++;
|
||||||
|
while (count--) {
|
||||||
|
*oPtr++ = pixel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fseek(raw->file, 512 + (y * raw->sizeX) + (z * raw->sizeX * raw->sizeY),
|
||||||
|
SEEK_SET);
|
||||||
|
fread(buf, 1, raw->sizeX, raw->file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
RawImageGetData(rawImageRec * raw, TK_RGBImageRec * final)
|
||||||
|
{
|
||||||
|
unsigned char *ptr;
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
final->data =
|
||||||
|
(unsigned char *) malloc((raw->sizeX + 1) * (raw->sizeY + 1) * 4);
|
||||||
|
if (final->data == NULL) {
|
||||||
|
fprintf(stderr, "Out of memory!\n");
|
||||||
|
tkQuit();
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr = final->data;
|
||||||
|
for (i = 0; i < (int) (raw->sizeY); i++) {
|
||||||
|
RawImageGetRow(raw, raw->tmpR, i, 0);
|
||||||
|
RawImageGetRow(raw, raw->tmpG, i, 1);
|
||||||
|
RawImageGetRow(raw, raw->tmpB, i, 2);
|
||||||
|
if (raw->sizeZ == 4) {
|
||||||
|
/* 4 components */
|
||||||
|
RawImageGetRow(raw, raw->tmpA, i, 3);
|
||||||
|
for (j = 0; j < (int) (raw->sizeX); j++) {
|
||||||
|
*ptr++ = *(raw->tmpR + j);
|
||||||
|
*ptr++ = *(raw->tmpG + j);
|
||||||
|
*ptr++ = *(raw->tmpB + j);
|
||||||
|
*ptr++ = *(raw->tmpA + j);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* 3 components */
|
||||||
|
for (j = 0; j < (int) (raw->sizeX); j++) {
|
||||||
|
*ptr++ = *(raw->tmpR + j);
|
||||||
|
*ptr++ = *(raw->tmpG + j);
|
||||||
|
*ptr++ = *(raw->tmpB + j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TK_RGBImageRec *
|
||||||
|
tkRGBImageLoad(const char *fileName)
|
||||||
|
{
|
||||||
|
rawImageRec *raw;
|
||||||
|
TK_RGBImageRec *final;
|
||||||
|
|
||||||
|
raw = RawImageOpen(fileName);
|
||||||
|
final = (TK_RGBImageRec *) malloc(sizeof (TK_RGBImageRec));
|
||||||
|
if (final == NULL) {
|
||||||
|
fprintf(stderr, "Out of memory!\n");
|
||||||
|
tkQuit();
|
||||||
|
}
|
||||||
|
final->sizeX = raw->sizeX;
|
||||||
|
final->sizeY = raw->sizeY;
|
||||||
|
final->sizeZ = raw->sizeZ;
|
||||||
|
RawImageGetData(raw, final);
|
||||||
|
RawImageClose(raw);
|
||||||
|
return final;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
14
ng/Togl2.1/image.h
Normal file
14
ng/Togl2.1/image.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/* image.h */
|
||||||
|
|
||||||
|
#ifndef IMAGE_H
|
||||||
|
# define IMAGE_H
|
||||||
|
|
||||||
|
typedef struct _TK_RGBImageRec
|
||||||
|
{
|
||||||
|
int sizeX, sizeY, sizeZ;
|
||||||
|
unsigned char *data;
|
||||||
|
} TK_RGBImageRec;
|
||||||
|
|
||||||
|
extern TK_RGBImageRec *tkRGBImageLoad(const char *fileName);
|
||||||
|
|
||||||
|
#endif
|
227
ng/Togl2.1/index.c
Normal file
227
ng/Togl2.1/index.c
Normal file
@ -0,0 +1,227 @@
|
|||||||
|
/* $Id: index.c,v 1.13 2007/08/03 16:48:50 gregcouch Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl - a Tk OpenGL widget
|
||||||
|
* Copyright (C) 1996-1997 Brian Paul and Ben Bederson
|
||||||
|
* Copyright (C) 2006-2007 Greg Couch
|
||||||
|
* See the LICENSE file for copyright details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* An example Togl program using color-index mode.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define USE_TOGL_STUBS
|
||||||
|
|
||||||
|
#include "togl.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#undef TCL_STORAGE_CLASS
|
||||||
|
#define TCL_STORAGE_CLASS DLLEXPORT
|
||||||
|
|
||||||
|
|
||||||
|
/* Our color indexes: */
|
||||||
|
static unsigned long black, red, green, blue;
|
||||||
|
|
||||||
|
/* Rotation angle */
|
||||||
|
static float Angle = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl widget create callback. This is called by Tcl/Tk when the widget has
|
||||||
|
* been realized. Here's where one may do some one-time context setup or
|
||||||
|
* initializations.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
create_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* allocate color indexes */
|
||||||
|
black = Togl_AllocColor(togl, 0, 0, 0);
|
||||||
|
red = Togl_AllocColor(togl, 1, 0, 0);
|
||||||
|
green = Togl_AllocColor(togl, 0, 1, 0);
|
||||||
|
blue = Togl_AllocColor(togl, 0, 0, 1);
|
||||||
|
|
||||||
|
/* If we were using a private read/write colormap we'd setup our color
|
||||||
|
* table with something like this: */
|
||||||
|
/*
|
||||||
|
* black = 1; Togl_SetColor( togl, black, 0, 0, 0 ); red = 2;
|
||||||
|
* Togl_SetColor( togl, red, 1, 0, 0 ); green = 3; Togl_SetColor(
|
||||||
|
* togl, green, 0, 1, 0 ); blue = 4; Togl_SetColor( togl, blue, 0,
|
||||||
|
* 0, 1 ); */
|
||||||
|
|
||||||
|
glShadeModel(GL_FLAT);
|
||||||
|
glDisable(GL_DITHER);
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl widget reshape callback. This is called by Tcl/Tk when the widget
|
||||||
|
* has been resized. Typically, we call glViewport and perhaps setup the
|
||||||
|
* projection matrix.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
reshape_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
float aspect;
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
width = Togl_Width(togl);
|
||||||
|
height = Togl_Height(togl);
|
||||||
|
aspect = (float) width / (float) height;
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
|
||||||
|
/* Set up projection transform */
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrtho(-aspect, aspect, -1, 1, -1, 1);
|
||||||
|
|
||||||
|
/* Change back to model view transform for rendering */
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl widget display callback. This is called by Tcl/Tk when the widget's
|
||||||
|
* contents have to be redrawn. Typically, we clear the color and depth
|
||||||
|
* buffers, render our objects, then swap the front/back color buffers.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
display_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
glClearIndex((float) black);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(0.3f, -0.3f, 0);
|
||||||
|
glRotatef(Angle, 0, 0, 1);
|
||||||
|
glIndexi(red);
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
glVertex2f(-0.5f, -0.3f);
|
||||||
|
glVertex2f(0.5f, -0.3f);
|
||||||
|
glVertex2f(0, 0.6f);
|
||||||
|
glEnd();
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
glRotatef(Angle, 0, 0, 1);
|
||||||
|
glIndexi(green);
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
glVertex2f(-0.5f, -0.3f);
|
||||||
|
glVertex2f(0.5f, -0.3f);
|
||||||
|
glVertex2f(0, 0.6f);
|
||||||
|
glEnd();
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(-0.3f, 0.3f, 0);
|
||||||
|
glRotatef(Angle, 0, 0, 1);
|
||||||
|
glIndexi(blue);
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
glVertex2f(-0.5f, -0.3f);
|
||||||
|
glVertex2f(0.5f, -0.3f);
|
||||||
|
glVertex2f(0, 0.6f);
|
||||||
|
glEnd();
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
glFlush();
|
||||||
|
Togl_SwapBuffers(togl);
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
timer_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
Angle += 5.0;
|
||||||
|
Togl_PostRedisplay(togl);
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EXTERN int
|
||||||
|
Index_Init(Tcl_Interp *interp)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Initialize Tcl and the Togl widget module.
|
||||||
|
*/
|
||||||
|
if (Tcl_InitStubs(interp, "8.1", 0) == NULL
|
||||||
|
|| Togl_InitStubs(interp, "2.0", 0) == NULL) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Specify the C callback functions for widget creation, display,
|
||||||
|
* and reshape.
|
||||||
|
*/
|
||||||
|
Tcl_CreateObjCommand(interp, "::index::create_cb", create_cb, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "::index::display_cb", display_cb, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "::index::reshape_cb", reshape_cb, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "::index::timer_cb", timer_cb, NULL, NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make a new Togl widget command so the Tcl code can set a C variable.
|
||||||
|
*/
|
||||||
|
/* NONE */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Call Tcl_CreateCommand for application-specific commands, if
|
||||||
|
* they weren't already created by the init procedures called above.
|
||||||
|
*/
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
50
ng/Togl2.1/index.tcl
Normal file
50
ng/Togl2.1/index.tcl
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# the next line restarts using tclsh \
|
||||||
|
exec tclsh "$0" "$@"
|
||||||
|
|
||||||
|
# $Id: index.tcl,v 1.8 2007/08/03 16:48:50 gregcouch Exp $
|
||||||
|
|
||||||
|
# Togl - a Tk OpenGL widget
|
||||||
|
# Copyright (C) 1996 Brian Paul and Ben Bederson
|
||||||
|
# Copyright (C) 2006-2007 Greg Couch
|
||||||
|
# See the LICENSE file for copyright details.
|
||||||
|
|
||||||
|
|
||||||
|
# A Tk/OpenGL widget demo using color-index mode.
|
||||||
|
|
||||||
|
package provide index 1.0
|
||||||
|
|
||||||
|
# add parent directory to path to find Togl's pkgIndex in current directory
|
||||||
|
if { [file exists pkgIndex.tcl] } {
|
||||||
|
set auto_path [linsert $auto_path 0 ..]
|
||||||
|
}
|
||||||
|
# following load also loads Tk and Togl packages
|
||||||
|
load [file dirname [info script]]/index[info sharedlibextension]
|
||||||
|
|
||||||
|
# create ::index namespace
|
||||||
|
namespace eval ::index {
|
||||||
|
}
|
||||||
|
|
||||||
|
proc ::index::setup {} {
|
||||||
|
wm title . "Color index demo"
|
||||||
|
|
||||||
|
togl .win -width 200 -height 200 -rgba false -double true -privatecmap false -time 10 -timer ::index::timer_cb -create ::index::create_cb -reshape ::index::reshape_cb -display ::index::display_cb
|
||||||
|
button .photo -text "Take Photo" -command ::index::take_photo
|
||||||
|
button .btn -text Quit -command exit
|
||||||
|
|
||||||
|
pack .win -expand true -fill both
|
||||||
|
pack .photo -expand true -fill both
|
||||||
|
pack .btn -expand true -fill both
|
||||||
|
}
|
||||||
|
|
||||||
|
proc ::index::take_photo {} {
|
||||||
|
image create photo img
|
||||||
|
.win takephoto img
|
||||||
|
img write image.ppm -format ppm
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Execution starts here!
|
||||||
|
if { [info script] == $argv0 } {
|
||||||
|
::index::setup
|
||||||
|
}
|
96
ng/Togl2.1/multisample.tcl
Normal file
96
ng/Togl2.1/multisample.tcl
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# the next line restarts using tclsh \
|
||||||
|
exec tclsh "$0" "$@"
|
||||||
|
|
||||||
|
# $Id: multisample.tcl,v 1.3 2009/03/12 23:59:35 gregcouch Exp $
|
||||||
|
|
||||||
|
# Togl - a Tk OpenGL widget
|
||||||
|
# Copyright (C) 1996 Brian Paul and Ben Bederson
|
||||||
|
# Copyright (C) 2006-2007 Greg Couch
|
||||||
|
# See the LICENSE file for copyright details.
|
||||||
|
|
||||||
|
|
||||||
|
# An Tk/OpenGL widget demo with two windows, one aliased and the
|
||||||
|
# other multisampled. Reuse C code from double buffering demo.
|
||||||
|
|
||||||
|
package provide multisample 1.0
|
||||||
|
|
||||||
|
# add parent directory to path to find Togl's pkgIndex in current directory
|
||||||
|
if { [file exists pkgIndex.tcl] } {
|
||||||
|
set auto_path [linsert $auto_path 0 ..]
|
||||||
|
}
|
||||||
|
# following load also loads Tk and Togl packages
|
||||||
|
load [file dirname [info script]]/double[info sharedlibextension]
|
||||||
|
|
||||||
|
# create ::multisample namespace
|
||||||
|
namespace eval ::multisample {
|
||||||
|
}
|
||||||
|
|
||||||
|
proc multisample::setup {} {
|
||||||
|
wm title . "Multisample vs Aliased"
|
||||||
|
|
||||||
|
# create first Togl widget
|
||||||
|
togl .o1 -width 200 -height 200 -rgba true -double true -depth true -create double::create_cb -display double::display_cb -reshape double::reshape_cb -multisample false -ident Aliased
|
||||||
|
|
||||||
|
# create second Togl widget, share display lists with first widget
|
||||||
|
togl .o2 -width 200 -height 200 -rgba true -double true -depth true -create double::create_cb -display double::display_cb -reshape double::reshape_cb -multisample true -ident Multisampled -sharelist Aliased
|
||||||
|
|
||||||
|
scale .sx -label {X Axis} -from 0 -to 360 -command {::multisample::setAngle x} -orient horizontal
|
||||||
|
scale .sy -label {Y Axis} -from 0 -to 360 -command {::multisample::setAngle y} -orient horizontal
|
||||||
|
button .btn -text Quit -command exit
|
||||||
|
|
||||||
|
bind .o1 <B1-Motion> {
|
||||||
|
::multisample::motion_event [lindex [%W config -width] 4] \
|
||||||
|
[lindex [%W config -height] 4] \
|
||||||
|
%x %y
|
||||||
|
}
|
||||||
|
|
||||||
|
bind .o2 <B1-Motion> {
|
||||||
|
::multisample::motion_event [lindex [%W config -width] 4] \
|
||||||
|
[lindex [%W config -height] 4] \
|
||||||
|
%x %y
|
||||||
|
}
|
||||||
|
|
||||||
|
grid rowconfigure . 0 -weight 1
|
||||||
|
grid columnconfigure . 0 -weight 1 -uniform same
|
||||||
|
grid columnconfigure . 1 -weight 1 -uniform same
|
||||||
|
grid .o1 -row 0 -column 0 -sticky nesw -padx 3 -pady 3
|
||||||
|
grid .o2 -row 0 -column 1 -sticky nesw -padx 3 -pady 3
|
||||||
|
#grid .l1 -row 1 -column 0 -sticky ew -padx 3 -pady 3
|
||||||
|
#grid .l2 -row 1 -column 1 -sticky ew -padx 3 -pady 3
|
||||||
|
grid .sx -row 2 -column 0 -columnspan 2 -sticky ew
|
||||||
|
grid .sy -row 3 -column 0 -columnspan 2 -sticky ew
|
||||||
|
grid .btn -row 4 -column 0 -columnspan 2 -sticky ew
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# This is called when mouse button 1 is pressed and moved in either of
|
||||||
|
# the OpenGL windows.
|
||||||
|
proc multisample::motion_event { width height x y } {
|
||||||
|
.sx set [double::setXrot [expr 360.0 * $y / $height]]
|
||||||
|
.sy set [double::setYrot [expr 360.0 * ($width - $x) / $width]]
|
||||||
|
|
||||||
|
.o1 postredisplay
|
||||||
|
.o2 postredisplay
|
||||||
|
}
|
||||||
|
|
||||||
|
# This is called when a slider is changed.
|
||||||
|
proc multisample::setAngle {axis value} {
|
||||||
|
global xAngle yAngle zAngle
|
||||||
|
|
||||||
|
switch -exact $axis {
|
||||||
|
x {double::setXrot $value
|
||||||
|
double::setXrot $value}
|
||||||
|
y {double::setYrot $value
|
||||||
|
double::setYrot $value}
|
||||||
|
}
|
||||||
|
|
||||||
|
.o1 postredisplay
|
||||||
|
.o2 postredisplay
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execution starts here!
|
||||||
|
if { [info script] == $argv0 } {
|
||||||
|
::multisample::setup
|
||||||
|
}
|
214
ng/Togl2.1/overlay.c
Normal file
214
ng/Togl2.1/overlay.c
Normal file
@ -0,0 +1,214 @@
|
|||||||
|
/* $Id: overlay.c,v 1.10 2007/08/03 16:48:50 gregcouch Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl - a Tk OpenGL widget
|
||||||
|
* Copyright (C) 1996-1997 Brian Paul and Ben Bederson
|
||||||
|
* Copyright (C) 2006-2007 Greg Couch
|
||||||
|
* See the LICENSE file for copyright details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* An example Togl program using an overlay.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define USE_TOGL_STUBS
|
||||||
|
|
||||||
|
#include "togl.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#undef TCL_STORAGE_CLASS
|
||||||
|
#define TCL_STORAGE_CLASS DLLEXPORT
|
||||||
|
|
||||||
|
|
||||||
|
/* Overlay color indexes: */
|
||||||
|
static unsigned long Red, Green;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl widget create callback. This is called by Tcl/Tk when the widget has
|
||||||
|
* been realized. Here's where one may do some one-time context setup or
|
||||||
|
* initializations.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
create_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* allocate overlay color indexes */
|
||||||
|
Red = Togl_AllocColorOverlay(togl, 1, 0, 0);
|
||||||
|
Green = Togl_AllocColorOverlay(togl, 0, 1, 0);
|
||||||
|
|
||||||
|
/* in this demo we always show the overlay */
|
||||||
|
if (Togl_ExistsOverlay(togl)) {
|
||||||
|
Togl_ShowOverlay(togl);
|
||||||
|
printf("Red and green lines are in the overlay\n");
|
||||||
|
} else {
|
||||||
|
printf("Sorry, this display doesn't support overlays\n");
|
||||||
|
}
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl widget reshape callback. This is called by Tcl/Tk when the widget
|
||||||
|
* has been resized. Typically, we call glViewport and perhaps setup the
|
||||||
|
* projection matrix.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
reshape_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
float aspect;
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
width = Togl_Width(togl);
|
||||||
|
height = Togl_Height(togl);
|
||||||
|
aspect = (float) width / (float) height;
|
||||||
|
|
||||||
|
/* Set up viewing for normal plane's context */
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrtho(-aspect, aspect, -1, 1, -1, 1);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
||||||
|
/* Set up viewing for overlay plane's context */
|
||||||
|
if (Togl_ExistsOverlay(togl)) {
|
||||||
|
Togl_UseLayer(togl, TOGL_OVERLAY);
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrtho(-1, 1, -1, 1, -1, 1);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
Togl_UseLayer(togl, TOGL_NORMAL);
|
||||||
|
}
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl widget overlay display callback. This is called by Tcl/Tk when the
|
||||||
|
* overlay has to be redrawn.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
overlay_display_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
glIndexi(Red);
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
glVertex2f(-1, -1);
|
||||||
|
glVertex2f(1, 1);
|
||||||
|
glVertex2f(-1, 1);
|
||||||
|
glVertex2f(1, -1);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glIndexi(Green);
|
||||||
|
glBegin(GL_LINE_LOOP);
|
||||||
|
glVertex2f(-0.5f, -0.5f);
|
||||||
|
glVertex2f(0.5f, -0.5f);
|
||||||
|
glVertex2f(0.5f, 0.5f);
|
||||||
|
glVertex2f(-0.5f, 0.5f);
|
||||||
|
glEnd();
|
||||||
|
glFlush();
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl widget display callback. This is called by Tcl/Tk when the widget's
|
||||||
|
* contents have to be redrawn. Typically, we clear the color and depth
|
||||||
|
* buffers, render our objects, then swap the front/back color buffers.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
display_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
|
||||||
|
glColor3f(1, 0, 1);
|
||||||
|
glVertex2f(-0.5f, -0.3f);
|
||||||
|
glVertex2f(0.5f, -0.3f);
|
||||||
|
glVertex2f(0, 0.6f);
|
||||||
|
|
||||||
|
glColor3f(1, 1, 0);
|
||||||
|
glVertex2f(-0.5f + 0.2f, -0.3f - 0.2f);
|
||||||
|
glVertex2f(0.5f + 0.2f, -0.3f - 0.2f);
|
||||||
|
glVertex2f(0 + 0.2f, 0.6f - 0.2f);
|
||||||
|
|
||||||
|
glColor3f(0, 1, 1);
|
||||||
|
glVertex2f(-0.5f + 0.4f, -0.3f - 0.4f);
|
||||||
|
glVertex2f(0.5f + 0.4f, -0.3f - 0.4f);
|
||||||
|
glVertex2f(0 + 0.4f, 0.6f - 0.4f);
|
||||||
|
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glFlush();
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called by Tcl to let me initialize the modules (Togl) I will need.
|
||||||
|
*/
|
||||||
|
EXTERN int
|
||||||
|
Overlay_Init(Tcl_Interp *interp)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Initialize Tcl and the Togl widget module.
|
||||||
|
*/
|
||||||
|
if (Tcl_InitStubs(interp, "8.1", 0) == NULL
|
||||||
|
|| Togl_InitStubs(interp, "2.0", 0) == NULL) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Specify the C callback functions for widget creation, display,
|
||||||
|
* and reshape.
|
||||||
|
*/
|
||||||
|
Tcl_CreateObjCommand(interp, "create_cb", create_cb, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "display_cb", display_cb, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "reshape_cb", reshape_cb, NULL, NULL);
|
||||||
|
|
||||||
|
Tcl_CreateObjCommand(interp, "overlay_display_cb", overlay_display_cb, NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make a new Togl widget command so the Tcl code can set a C variable.
|
||||||
|
*/
|
||||||
|
/* NONE */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Call Tcl_CreateCommand for application-specific commands, if
|
||||||
|
* they weren't already created by the init procedures called above.
|
||||||
|
*/
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
37
ng/Togl2.1/overlay.tcl
Normal file
37
ng/Togl2.1/overlay.tcl
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# the next line restarts using tclsh \
|
||||||
|
exec tclsh "$0" "$@"
|
||||||
|
|
||||||
|
# $Id: overlay.tcl,v 1.7 2007/08/03 16:48:50 gregcouch Exp $
|
||||||
|
|
||||||
|
# Togl - a Tk OpenGL widget
|
||||||
|
# Copyright (C) 1996 Brian Paul and Ben Bederson
|
||||||
|
# Copyright (C) 2006-2007 Greg Couch
|
||||||
|
# See the LICENSE file for copyright details.
|
||||||
|
|
||||||
|
|
||||||
|
# A Tk/OpenGL widget demo using an overlay.
|
||||||
|
|
||||||
|
# add parent directory to path to find Togl's pkgIndex in current directory
|
||||||
|
if { [file exists pkgIndex.tcl] } {
|
||||||
|
set auto_path [linsert $auto_path 0 ..]
|
||||||
|
}
|
||||||
|
# following load also loads Tk and Togl packages
|
||||||
|
load [file dirname [info script]]/overlay[info sharedlibextension]
|
||||||
|
|
||||||
|
proc setup {} {
|
||||||
|
wm title . "Overlay demo"
|
||||||
|
|
||||||
|
togl .win -width 200 -height 200 -rgba true -double false -overlay true -create create_cb -reshape reshape_cb -display display_cb -overlaydisplay overlay_display_cb
|
||||||
|
button .btn -text Quit -command exit
|
||||||
|
|
||||||
|
pack .win -expand true -fill both
|
||||||
|
pack .btn -expand true -fill both
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Execution starts here!
|
||||||
|
# Execution starts here!
|
||||||
|
if { [info script] == $argv0 } {
|
||||||
|
setup
|
||||||
|
}
|
489
ng/Togl2.1/pbuffer.c
Normal file
489
ng/Togl2.1/pbuffer.c
Normal file
@ -0,0 +1,489 @@
|
|||||||
|
/* $Id: pbuffer.c,v 1.2 2009/02/05 06:57:10 gregcouch Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl - a Tk OpenGL widget
|
||||||
|
* Copyright (C) 1996-1997 Brian Paul and Ben Bederson
|
||||||
|
* Copyright (C) 2006-2007 Greg Couch
|
||||||
|
* See the LICENSE file for copyright details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#undef PBUFFER_DEBUG
|
||||||
|
|
||||||
|
#define USE_TOGL_STUBS
|
||||||
|
|
||||||
|
#include "togl.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
#if defined(TOGL_AGL)
|
||||||
|
# include <OpenGL/glu.h>
|
||||||
|
# include <AGL/agl.h>
|
||||||
|
#elif defined(TOGL_NSOPENGL)
|
||||||
|
# include <OpenGL/glu.h>
|
||||||
|
# include <OpenGL/OpenGL.h>
|
||||||
|
#else
|
||||||
|
# include <GL/glu.h>
|
||||||
|
#endif
|
||||||
|
#include <GL/glext.h> /* OpenGL 1.4 GL_GENERATE_MIPMAP */
|
||||||
|
|
||||||
|
#undef TCL_STORAGE_CLASS
|
||||||
|
#define TCL_STORAGE_CLASS DLLEXPORT
|
||||||
|
|
||||||
|
static double xAngle = 0, yAngle = 0, zAngle = 0;
|
||||||
|
static GLdouble CornerX, CornerY, CornerZ; /* where to print strings */
|
||||||
|
static GLuint texture;
|
||||||
|
static Togl *output;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl widget create callback. This is called by Tcl/Tk when the widget has
|
||||||
|
* been realized. Here's where one may do some one-time context setup or
|
||||||
|
* initializations.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
create_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
Togl *togl;
|
||||||
|
double version;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
version = atof((const char *) glGetString(GL_VERSION));
|
||||||
|
if (version < 1.4) {
|
||||||
|
Tcl_SetResult(interp, "need OpenGL 1.4 or later", TCL_STATIC);
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl widget reshape callback. This is called by Tcl/Tk when the widget
|
||||||
|
* has been resized. Typically, we call glViewport and perhaps setup the
|
||||||
|
* projection matrix.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
reshape_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
double aspect;
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
width = Togl_Width(togl);
|
||||||
|
height = Togl_Height(togl);
|
||||||
|
aspect = (double) width / (double) height;
|
||||||
|
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
|
||||||
|
/* Set up projection transform */
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glFrustum(-aspect, aspect, -1, 1, 1, 10);
|
||||||
|
|
||||||
|
CornerX = -aspect;
|
||||||
|
CornerY = -1;
|
||||||
|
CornerZ = -1.1;
|
||||||
|
|
||||||
|
/* Change back to model view transform for rendering */
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl widget reshape callback. This is called by Tcl/Tk when the widget
|
||||||
|
* has been resized. Typically, we call glViewport and perhaps setup the
|
||||||
|
* projection matrix.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
reshape2_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
double aspect;
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
width = Togl_Width(togl);
|
||||||
|
height = Togl_Height(togl);
|
||||||
|
aspect = (double) width / (double) height;
|
||||||
|
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
|
||||||
|
/* Set up projection transform */
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrtho(-aspect, aspect, -1, 1, -1, 1);
|
||||||
|
|
||||||
|
/* Change back to model view transform for rendering */
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
draw_object()
|
||||||
|
{
|
||||||
|
static GLuint cubeList = 0;
|
||||||
|
|
||||||
|
glLoadIdentity(); /* Reset modelview matrix to the identity
|
||||||
|
* matrix */
|
||||||
|
glTranslatef(0, 0, -3); /* Move the camera back three units */
|
||||||
|
glRotated(xAngle, 1, 0, 0); /* Rotate by X, Y, and Z angles */
|
||||||
|
glRotated(yAngle, 0, 1, 0);
|
||||||
|
glRotated(zAngle, 0, 0, 1);
|
||||||
|
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
if (!cubeList) {
|
||||||
|
cubeList = glGenLists(1);
|
||||||
|
glNewList(cubeList, GL_COMPILE);
|
||||||
|
|
||||||
|
/* Front face */
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glColor3f(0, 0.7f, 0.1f); /* Green */
|
||||||
|
glVertex3f(-1, 1, 1);
|
||||||
|
glVertex3f(1, 1, 1);
|
||||||
|
glVertex3f(1, -1, 1);
|
||||||
|
glVertex3f(-1, -1, 1);
|
||||||
|
/* Back face */
|
||||||
|
glColor3f(0.9f, 1, 0); /* Yellow */
|
||||||
|
glVertex3f(-1, 1, -1);
|
||||||
|
glVertex3f(1, 1, -1);
|
||||||
|
glVertex3f(1, -1, -1);
|
||||||
|
glVertex3f(-1, -1, -1);
|
||||||
|
/* Top side face */
|
||||||
|
glColor3f(0.2f, 0.2f, 1); /* Blue */
|
||||||
|
glVertex3f(-1, 1, 1);
|
||||||
|
glVertex3f(1, 1, 1);
|
||||||
|
glVertex3f(1, 1, -1);
|
||||||
|
glVertex3f(-1, 1, -1);
|
||||||
|
/* Bottom side face */
|
||||||
|
glColor3f(0.7f, 0, 0.1f); /* Red */
|
||||||
|
glVertex3f(-1, -1, 1);
|
||||||
|
glVertex3f(1, -1, 1);
|
||||||
|
glVertex3f(1, -1, -1);
|
||||||
|
glVertex3f(-1, -1, -1);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glEndList();
|
||||||
|
|
||||||
|
}
|
||||||
|
glCallList(cubeList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl widget display callback. This is called by Tcl/Tk when the widget's
|
||||||
|
* contents have to be redrawn. Typically, we clear the color and depth
|
||||||
|
* buffers, render our objects, then swap the front/back color buffers.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
display_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK)
|
||||||
|
return TCL_ERROR;
|
||||||
|
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
draw_object();
|
||||||
|
|
||||||
|
#ifdef PBUFFER_DEBUG
|
||||||
|
{
|
||||||
|
Tk_PhotoHandle photo;
|
||||||
|
|
||||||
|
/* first tcl: image create photo test */
|
||||||
|
photo = Tk_FindPhoto(interp, "test2");
|
||||||
|
if (photo == NULL) {
|
||||||
|
fprintf(stderr, "missing tk photo object test2\n");
|
||||||
|
} else {
|
||||||
|
Togl_TakePhoto(togl, photo);
|
||||||
|
Tcl_Eval(interp, "test2 write test2.ppm -format ppm");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
Togl_SwapBuffers(togl);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl widget display callback. This is called by Tcl/Tk when the widget's
|
||||||
|
* contents have to be redrawn. Typically, we clear the color and depth
|
||||||
|
* buffers, render our objects, then swap the front/back color buffers.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
display2_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK)
|
||||||
|
return TCL_ERROR;
|
||||||
|
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
if (texture) {
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glTexCoord2i(0, 0);
|
||||||
|
glVertex2i(-1, -1);
|
||||||
|
glTexCoord2i(1, 0);
|
||||||
|
glVertex2i(1, -1);
|
||||||
|
glTexCoord2i(1, 1);
|
||||||
|
glVertex2i(1, 1);
|
||||||
|
glTexCoord2i(0, 1);
|
||||||
|
glVertex2i(-1, 1);
|
||||||
|
glEnd();
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Togl_SwapBuffers(togl);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl widget display callback. This is called by Tcl/Tk when the widget's
|
||||||
|
* contents have to be redrawn. Typically, we clear the color and depth
|
||||||
|
* buffers, render our objects, then swap the front/back color buffers.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
pbuffer_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
Togl *togl;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
GLenum error;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK)
|
||||||
|
return TCL_ERROR;
|
||||||
|
|
||||||
|
width = Togl_Width(togl);
|
||||||
|
height = Togl_Height(togl);
|
||||||
|
|
||||||
|
if (texture == 0) {
|
||||||
|
glGenTextures(1, &texture);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
#if !defined(TOGL_AGL) && !defined(TOGL_NSOPENGL)
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||||
|
GL_LINEAR_MIPMAP_LINEAR);
|
||||||
|
#else
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
#endif
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB,
|
||||||
|
GL_BYTE, NULL);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
error = glGetError();
|
||||||
|
if (error != GL_NO_ERROR) {
|
||||||
|
fprintf(stderr, "texture init: %s\n", gluErrorString(error));
|
||||||
|
}
|
||||||
|
#if 0 && defined(TOGL_AGL)
|
||||||
|
AGLContext ctx = aglGetCurrentContext();
|
||||||
|
AGLPbuffer pbuf;
|
||||||
|
GLint face, level, screen;
|
||||||
|
GLenum err;
|
||||||
|
|
||||||
|
aglGetPBuffer(ctx, &pbuf, &face, &level, &screen);
|
||||||
|
err = aglGetError();
|
||||||
|
if (err != AGL_NO_ERROR)
|
||||||
|
fprintf(stderr, "getPBuffer: %s\n", aglErrorString(err));
|
||||||
|
aglTexImagePBuffer(ctx, pbuf, GL_FRONT);
|
||||||
|
err = aglGetError();
|
||||||
|
if (err != AGL_NO_ERROR)
|
||||||
|
fprintf(stderr, "teximagepbuffer: %s\n", aglErrorString(err));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
draw_object();
|
||||||
|
|
||||||
|
#if 1 || !defined(TOGL_AGL)
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
|
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, width, height);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
error = glGetError();
|
||||||
|
if (error != GL_NO_ERROR) {
|
||||||
|
fprintf(stderr, "after tex copy: %s\n", gluErrorString(error));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef PBUFFER_DEBUG
|
||||||
|
{
|
||||||
|
Tk_PhotoHandle photo;
|
||||||
|
|
||||||
|
/* first tcl: image create photo test */
|
||||||
|
photo = Tk_FindPhoto(interp, "test");
|
||||||
|
Togl_TakePhoto(togl, photo);
|
||||||
|
Tcl_Eval(interp, "test write test.ppm -format ppm");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
Togl_SwapBuffers(togl);
|
||||||
|
if (output)
|
||||||
|
Togl_PostRedisplay(output);
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
setXrot_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "angle");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Tcl_GetDoubleFromObj(interp, objv[1], &xAngle) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* printf( "before %f ", xAngle ); */
|
||||||
|
|
||||||
|
xAngle = fmod(xAngle, 360.0);
|
||||||
|
if (xAngle < 0.0)
|
||||||
|
xAngle += 360.0;
|
||||||
|
|
||||||
|
/* printf( "after %f \n", xAngle ); */
|
||||||
|
|
||||||
|
/* Let result string equal value */
|
||||||
|
Tcl_SetObjResult(interp, objv[1]);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
setYrot_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "angle");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Tcl_GetDoubleFromObj(interp, objv[1], &yAngle) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
yAngle = fmod(yAngle, 360.0);
|
||||||
|
if (yAngle < 0.0)
|
||||||
|
yAngle += 360.0;
|
||||||
|
|
||||||
|
/* Let result equal value */
|
||||||
|
Tcl_SetObjResult(interp, objv[1]);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
setOutput_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &output) != TCL_OK)
|
||||||
|
return TCL_ERROR;
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called by Tcl to let me initialize the modules (Togl) I will need.
|
||||||
|
*/
|
||||||
|
EXTERN int
|
||||||
|
Pbuffer_Init(Tcl_Interp *interp)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Initialize Tcl and the Togl widget module.
|
||||||
|
*/
|
||||||
|
if (Tcl_InitStubs(interp, "8.1", 0) == NULL
|
||||||
|
#ifdef PBUFFER_DEBUG
|
||||||
|
|| Tk_InitStubs(interp, "8.1", 0) == NULL
|
||||||
|
#endif
|
||||||
|
|| Togl_InitStubs(interp, "2.0", 0) == NULL) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Specify the C callback functions for widget creation, display,
|
||||||
|
* and reshape.
|
||||||
|
*/
|
||||||
|
Tcl_CreateObjCommand(interp, "create_cb", create_cb, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "display_cb", display_cb, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "display2_cb", display2_cb, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "pbuffer_cb", pbuffer_cb, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "reshape_cb", reshape_cb, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "reshape2_cb", reshape2_cb, NULL, NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make a new Togl widget command so the Tcl code can set a C variable.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Tcl_CreateObjCommand(interp, "setXrot", setXrot_cb, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "setYrot", setYrot_cb, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "setOutput", setOutput_cb, NULL, NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Call Tcl_CreateCommand for application-specific commands, if
|
||||||
|
* they weren't already created by the init procedures called above.
|
||||||
|
*/
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
115
ng/Togl2.1/pbuffer.tcl
Normal file
115
ng/Togl2.1/pbuffer.tcl
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# the next line restarts using tclsh \
|
||||||
|
exec tclsh "$0" "$@"
|
||||||
|
|
||||||
|
# $Id: pbuffer.tcl,v 1.1 2009/01/29 22:45:46 gregcouch Exp $
|
||||||
|
|
||||||
|
# Togl - a Tk OpenGL widget
|
||||||
|
# Copyright (C) 1996 Brian Paul and Ben Bederson
|
||||||
|
# Copyright (C) 2006-2007 Greg Couch
|
||||||
|
# See the LICENSE file for copyright details.
|
||||||
|
|
||||||
|
|
||||||
|
# An Tk/OpenGL widget demo with two double-buffered OpenGL windows.
|
||||||
|
# The first shows the aliased object, the second show the results of
|
||||||
|
# rendering the same object in a higher resolution Pbuffer and using
|
||||||
|
# texture mapping to antialias it.
|
||||||
|
|
||||||
|
package provide pbuffer 1.0
|
||||||
|
|
||||||
|
# add parent directory to path to find Togl's pkgIndex in current directory
|
||||||
|
if { [file exists pkgIndex.tcl] } {
|
||||||
|
set auto_path [linsert $auto_path 0 ..]
|
||||||
|
}
|
||||||
|
# following load also loads Tk and Togl packages
|
||||||
|
load [file dirname [info script]]/pbuffer[info sharedlibextension]
|
||||||
|
|
||||||
|
# create ::pbuffer namespace
|
||||||
|
namespace eval ::pbuffer {
|
||||||
|
}
|
||||||
|
|
||||||
|
proc pbuffer::setup {} {
|
||||||
|
wm title . "Pbuffer test"
|
||||||
|
|
||||||
|
#debug
|
||||||
|
image create photo test
|
||||||
|
image create photo test2
|
||||||
|
#end debug
|
||||||
|
|
||||||
|
# create first Togl widget
|
||||||
|
togl .o1 -width 300 -height 300 -rgba true -double true -depth true -ident main -create create_cb -reshape reshape_cb -display display_cb
|
||||||
|
label .l1 -text "RGB, Z, double"
|
||||||
|
|
||||||
|
# create second Togl widget, share display lists with first widget, no depth
|
||||||
|
togl .o2 -width 300 -height 300 -rgba true -double true -sharelist main -reshape reshape2_cb -display display2_cb -ident second
|
||||||
|
setOutput .o2
|
||||||
|
label .l2 -text "RGB from pbuffer texture"
|
||||||
|
|
||||||
|
# create off-screen pbuffer, share display lists with other widgets
|
||||||
|
# must power of 2 squared in size
|
||||||
|
togl .pbuf -width 2048 -height 2048 -rgba true -depth true -sharelist main -pbuffer 1 -reshape reshape_cb -display pbuffer_cb -ident pbuffer
|
||||||
|
|
||||||
|
scale .sx -label {X Axis} -from 0 -to 360 -command {::pbuffer::setAngle x} -orient horizontal
|
||||||
|
scale .sy -label {Y Axis} -from 0 -to 360 -command {::pbuffer::setAngle y} -orient horizontal
|
||||||
|
button .btn -text Quit -command exit
|
||||||
|
|
||||||
|
bind .o1 <B1-Motion> {
|
||||||
|
::pbuffer::motion_event [lindex [%W config -width] 4] \
|
||||||
|
[lindex [%W config -height] 4] \
|
||||||
|
%x %y
|
||||||
|
}
|
||||||
|
|
||||||
|
bind .o2 <B1-Motion> {
|
||||||
|
::pbuffer::motion_event [lindex [%W config -width] 4] \
|
||||||
|
[lindex [%W config -height] 4] \
|
||||||
|
%x %y
|
||||||
|
}
|
||||||
|
|
||||||
|
grid rowconfigure . 0 -weight 1
|
||||||
|
grid columnconfigure . 0 -weight 1 -uniform same
|
||||||
|
grid columnconfigure . 1 -weight 1 -uniform same
|
||||||
|
grid .o1 -row 0 -column 0 -sticky nesw -padx 3 -pady 3
|
||||||
|
grid .o2 -row 0 -column 1 -sticky nesw -padx 3 -pady 3
|
||||||
|
grid .l1 -row 1 -column 0 -sticky ew -padx 3 -pady 3
|
||||||
|
grid .l2 -row 1 -column 1 -sticky ew -padx 3 -pady 3
|
||||||
|
grid .sx -row 2 -column 0 -columnspan 2 -sticky ew
|
||||||
|
grid .sy -row 3 -column 0 -columnspan 2 -sticky ew
|
||||||
|
grid .btn -row 4 -column 0 -columnspan 2 -sticky ew
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
proc pbuffer::display { } {
|
||||||
|
pbuffer_cb .pbuf
|
||||||
|
.o2 postredisplay
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# This is called when mouse button 1 is pressed and moved in either of
|
||||||
|
# the OpenGL windows.
|
||||||
|
proc pbuffer::motion_event { width height x y } {
|
||||||
|
.sx set [setXrot [expr 360.0 * $y / $height]]
|
||||||
|
.sy set [setYrot [expr 360.0 * ($width - $x) / $width]]
|
||||||
|
|
||||||
|
.o1 postredisplay
|
||||||
|
.pbuf postredisplay
|
||||||
|
}
|
||||||
|
|
||||||
|
# This is called when a slider is changed.
|
||||||
|
proc pbuffer::setAngle {axis value} {
|
||||||
|
global xAngle yAngle zAngle
|
||||||
|
|
||||||
|
switch -exact $axis {
|
||||||
|
x {setXrot $value
|
||||||
|
setXrot $value}
|
||||||
|
y {setYrot $value
|
||||||
|
setYrot $value}
|
||||||
|
}
|
||||||
|
|
||||||
|
.o1 postredisplay
|
||||||
|
.pbuf postredisplay
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execution starts here!
|
||||||
|
if { [info script] == $argv0 } {
|
||||||
|
::pbuffer::setup
|
||||||
|
}
|
5
ng/Togl2.1/pkgIndex.tcl.in
Normal file
5
ng/Togl2.1/pkgIndex.tcl.in
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#
|
||||||
|
# Tcl package index file
|
||||||
|
#
|
||||||
|
package ifneeded @PACKAGE_NAME@ @PACKAGE_VERSION@ \
|
||||||
|
[list load [file join $dir @PKG_LIB_FILE@]]
|
343
ng/Togl2.1/stereo.c
Normal file
343
ng/Togl2.1/stereo.c
Normal file
@ -0,0 +1,343 @@
|
|||||||
|
/* $Id: stereo.c,v 1.14 2009/02/07 07:04:50 gregcouch Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl - a Tk OpenGL widget
|
||||||
|
* Copyright (C) 1996-1997 Brian Paul and Ben Bederson
|
||||||
|
* Copyright (C) 2006-2009 Greg Couch
|
||||||
|
* See the LICENSE file for copyright details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define USE_TOGL_STUBS
|
||||||
|
|
||||||
|
#include "togl.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#undef TCL_STORAGE_CLASS
|
||||||
|
#define TCL_STORAGE_CLASS DLLEXPORT
|
||||||
|
|
||||||
|
|
||||||
|
static Tcl_Obj *toglFont;
|
||||||
|
static double xAngle = 0, yAngle = 0, zAngle = 0;
|
||||||
|
static GLfloat CornerX, CornerY, CornerZ; /* where to print strings */
|
||||||
|
static double coord_scale = 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl widget create callback. This is called by Tcl/Tk when the widget has
|
||||||
|
* been realized. Here's where one may do some one-time context setup or
|
||||||
|
* initializations.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
create_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl widget reshape callback. This is called by Tcl/Tk when the widget
|
||||||
|
* has been resized. Typically, we call glViewport and perhaps setup the
|
||||||
|
* projection matrix.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
reshape_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
float aspect;
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
width = Togl_Width(togl);
|
||||||
|
height = Togl_Height(togl);
|
||||||
|
aspect = (float) width / (float) height;
|
||||||
|
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
|
||||||
|
/* Set up projection transform */
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glFrustum(-aspect, aspect, -1, 1, 1, 10);
|
||||||
|
|
||||||
|
CornerX = -aspect;
|
||||||
|
CornerY = -1;
|
||||||
|
CornerZ = -1.1f;
|
||||||
|
|
||||||
|
/* Change back to model view transform for rendering */
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
draw_eye(Togl *togl)
|
||||||
|
{
|
||||||
|
static GLuint cubeList = 0;
|
||||||
|
|
||||||
|
Togl_Clear(togl, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
Togl_Frustum(togl, -1, 1, -1, 1, 1, 10);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
||||||
|
if (!cubeList) {
|
||||||
|
cubeList = glGenLists(1);
|
||||||
|
glNewList(cubeList, GL_COMPILE);
|
||||||
|
|
||||||
|
/* Front face */
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glColor3f(0.4f, 0.8f, 0.4f); /* Green-ish */
|
||||||
|
glVertex3f(-1, 1, 1);
|
||||||
|
glVertex3f(1, 1, 1);
|
||||||
|
glVertex3f(1, -1, 1);
|
||||||
|
glVertex3f(-1, -1, 1);
|
||||||
|
/* Back face */
|
||||||
|
glColor3f(0.8f, 0.8f, 0.4f); /* Yellow-ish */
|
||||||
|
glVertex3f(-1, 1, -1);
|
||||||
|
glVertex3f(1, 1, -1);
|
||||||
|
glVertex3f(1, -1, -1);
|
||||||
|
glVertex3f(-1, -1, -1);
|
||||||
|
/* Top side face */
|
||||||
|
glColor3f(0.4f, 0.4f, 0.8f); /* Blue-ish */
|
||||||
|
glVertex3f(-1, 1, 1);
|
||||||
|
glVertex3f(1, 1, 1);
|
||||||
|
glVertex3f(1, 1, -1);
|
||||||
|
glVertex3f(-1, 1, -1);
|
||||||
|
/* Bottom side face */
|
||||||
|
glColor3f(0.8f, 0.4f, 0.4f); /* Red-ish */
|
||||||
|
glVertex3f(-1, -1, 1);
|
||||||
|
glVertex3f(1, -1, 1);
|
||||||
|
glVertex3f(1, -1, -1);
|
||||||
|
glVertex3f(-1, -1, -1);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glEndList();
|
||||||
|
}
|
||||||
|
glCallList(cubeList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl widget display callback. This is called by Tcl/Tk when the widget's
|
||||||
|
* contents have to be redrawn. Typically, we clear the color and depth
|
||||||
|
* buffers, render our objects, then swap the front/back color buffers.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
display_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* setup modelview matrix */
|
||||||
|
glLoadIdentity(); /* Reset modelview matrix to the identity
|
||||||
|
* matrix */
|
||||||
|
glTranslatef(0, 0, -3.0); /* Move the camera back three units */
|
||||||
|
glScaled(coord_scale, coord_scale, coord_scale); /* Zoom in and out */
|
||||||
|
glRotated(xAngle, 1, 0, 0); /* Rotate by X, Y, and Z angles */
|
||||||
|
glRotated(yAngle, 0, 1, 0);
|
||||||
|
glRotated(zAngle, 0, 0, 1);
|
||||||
|
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
if (Togl_NumEyes(togl) == 1) {
|
||||||
|
/* single eye */
|
||||||
|
Togl_DrawBuffer(togl, GL_BACK);
|
||||||
|
draw_eye(togl);
|
||||||
|
} else {
|
||||||
|
/* stereo left eye */
|
||||||
|
Togl_DrawBuffer(togl, GL_BACK_LEFT);
|
||||||
|
draw_eye(togl);
|
||||||
|
|
||||||
|
/* stereo right eye */
|
||||||
|
Togl_DrawBuffer(togl, GL_BACK_RIGHT);
|
||||||
|
draw_eye(togl);
|
||||||
|
}
|
||||||
|
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
glLoadIdentity();
|
||||||
|
glColor3f(1, 1, 1);
|
||||||
|
glRasterPos3f(CornerX, CornerY, CornerZ);
|
||||||
|
Togl_SwapBuffers(togl);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
setXrot_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 3) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName angle");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Tcl_GetDoubleFromObj(interp, objv[2], &xAngle) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* printf( "before %f ", xAngle ); */
|
||||||
|
|
||||||
|
if (xAngle < 0) {
|
||||||
|
xAngle += 360;
|
||||||
|
} else if (xAngle > 360) {
|
||||||
|
xAngle -= 360;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* printf( "after %f \n", xAngle ); */
|
||||||
|
|
||||||
|
Togl_PostRedisplay(togl);
|
||||||
|
|
||||||
|
/* Let result string equal value */
|
||||||
|
Tcl_SetObjResult(interp, objv[2]);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
setYrot_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 3) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName angle");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Tcl_GetDoubleFromObj(interp, objv[2], &yAngle) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (yAngle < 0) {
|
||||||
|
yAngle += 360;
|
||||||
|
} else if (yAngle > 360) {
|
||||||
|
yAngle -= 360;
|
||||||
|
}
|
||||||
|
|
||||||
|
Togl_PostRedisplay(togl);
|
||||||
|
|
||||||
|
/* Let result string equal value */
|
||||||
|
Tcl_SetObjResult(interp, objv[2]);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
getXrot_cb(ClientData clientData, Tcl_Interp *interp,
|
||||||
|
int argc, CONST84 char *argv[])
|
||||||
|
{
|
||||||
|
Tcl_SetObjResult(interp, Tcl_NewDoubleObj(xAngle));
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
getYrot_cb(ClientData clientData, Tcl_Interp *interp,
|
||||||
|
int argc, CONST84 char *argv[])
|
||||||
|
{
|
||||||
|
Tcl_SetObjResult(interp, Tcl_NewDoubleObj(yAngle));
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
coord_scale_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 3) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName value");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Tcl_GetDoubleFromObj(interp, objv[2], &coord_scale) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
Togl_PostRedisplay(togl);
|
||||||
|
|
||||||
|
/* Let result string equal value */
|
||||||
|
Tcl_SetObjResult(interp, objv[2]);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EXTERN int
|
||||||
|
Stereo_Init(Tcl_Interp *interp)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Initialize Tcl and the Togl widget module.
|
||||||
|
*/
|
||||||
|
if (Tcl_InitStubs(interp, "8.1", 0) == NULL
|
||||||
|
|| Togl_InitStubs(interp, "2.0", 0) == NULL) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Specify the C callback functions for widget creation, display,
|
||||||
|
* and reshape.
|
||||||
|
*/
|
||||||
|
Tcl_CreateObjCommand(interp, "create_cb", create_cb, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "display_cb", display_cb, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "reshape_cb", reshape_cb, NULL, NULL);
|
||||||
|
|
||||||
|
Tcl_CreateObjCommand(interp, "setXrot", setXrot_cb, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "setYrot", setYrot_cb, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "coord_scale", coord_scale_cb, NULL, NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Call Tcl_CreateCommand for application-specific commands, if
|
||||||
|
* they weren't already created by the init procedures called above.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Tcl_CreateCommand(interp, "getXrot", getXrot_cb, NULL, NULL);
|
||||||
|
Tcl_CreateCommand(interp, "getYrot", getYrot_cb, NULL, NULL);
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
106
ng/Togl2.1/stereo.tcl
Normal file
106
ng/Togl2.1/stereo.tcl
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# the next line restarts using tclsh \
|
||||||
|
exec tclsh "$0" "$@"
|
||||||
|
|
||||||
|
# $Id: stereo.tcl,v 1.13 2009/03/31 23:21:13 gregcouch Exp $
|
||||||
|
|
||||||
|
# Togl - a Tk OpenGL widget
|
||||||
|
# Copyright (C) 1996 Brian Paul and Ben Bederson
|
||||||
|
# Copyright (C) 2006-2009 Greg Couch
|
||||||
|
# See the LICENSE file for copyright details.
|
||||||
|
|
||||||
|
# add parent directory to path to find Togl's pkgIndex in current directory
|
||||||
|
if { [file exists pkgIndex.tcl] } {
|
||||||
|
set auto_path [linsert $auto_path 0 ..]
|
||||||
|
}
|
||||||
|
# following load also loads Tk and Togl packages
|
||||||
|
load [file dirname [info script]]/stereo[info sharedlibextension]
|
||||||
|
|
||||||
|
# create ::stereo namespace
|
||||||
|
namespace eval ::stereo {
|
||||||
|
}
|
||||||
|
|
||||||
|
variable stereo::mode none
|
||||||
|
proc stereo::setup {} {
|
||||||
|
grid rowconfigure . 0 -weight 1 -minsize 200p
|
||||||
|
grid columnconfigure . 1 -weight 1 -minsize 200p
|
||||||
|
labelframe .c -text "Stereo mode:"
|
||||||
|
grid .c -padx 2 -pady 2 -ipadx 2 -ipady 1
|
||||||
|
foreach {b} {none native sgioldstyle anaglyph cross-eye wall-eye DTI "row interleaved" "left eye" "right eye" } {
|
||||||
|
set name [string map {- _ " " _} $b]
|
||||||
|
radiobutton .c.b$name -text "$b" -command "::stereo::makeGraphics {$b}" -variable stereo::mode -value "$b"
|
||||||
|
pack .c.b$name -padx 2 -pady 1 -anchor w
|
||||||
|
}
|
||||||
|
scale .sx -label {X Axis} -from 0 -to 360 -command {::stereo::setAngle x} -orient horizontal
|
||||||
|
grid .sx -columnspan 2 -sticky ew
|
||||||
|
scale .sy -label {Y Axis} -from 0 -to 360 -command {::stereo::setAngle y} -orient horizontal
|
||||||
|
grid .sy -columnspan 2 -sticky ew
|
||||||
|
if {[string first IRIX $::tcl_platform(os)] != -1} {
|
||||||
|
label .irix -justify left -wraplength 250p -text "Use /usr/gfx/setmon or /usr/bin/X11/xsetmon to change video mode for native stereo (eg., 1024x768_120s) or sgioldstyle stereo (eg., str_bot) and back."
|
||||||
|
grid .irix -sticky new -columnspan 2
|
||||||
|
}
|
||||||
|
button .quit -text Close -command exit
|
||||||
|
grid .quit -sticky se -columnspan 2 -padx 2 -pady 2
|
||||||
|
frame .f -relief groove -borderwidth 2 -bg black
|
||||||
|
grid .f -row 0 -column 1 -sticky news
|
||||||
|
bind . <Key-Escape> {exit}
|
||||||
|
label .f.error -wraplength 100p -bg black -fg white
|
||||||
|
::stereo::makeGraphics $stereo::mode
|
||||||
|
}
|
||||||
|
|
||||||
|
set stereo::count 0
|
||||||
|
set stereo::gwidget ""
|
||||||
|
proc stereo::makeGraphics {mode} {
|
||||||
|
incr stereo::count
|
||||||
|
set name .f.gr$stereo::count
|
||||||
|
set width 200
|
||||||
|
set height 200
|
||||||
|
if { [catch { togl $name -width $width -height $height -rgba true -stereo "$mode" -double true -depth true -sharelist main -create create_cb -display display_cb -reshape reshape_cb -eyeseparation 0.05 -convergence 2.0 -stencil true } error] } {
|
||||||
|
pack forget $stereo::gwidget
|
||||||
|
.f.error configure -text "$error\n\nMake another choice from the stereo modes on the left."
|
||||||
|
pack .f.error -expand 1 -fill both
|
||||||
|
} else {
|
||||||
|
pack forget .f.error
|
||||||
|
$name configure -ident main
|
||||||
|
if { "$stereo::gwidget" != "" } {
|
||||||
|
destroy $stereo::gwidget
|
||||||
|
}
|
||||||
|
set stereo::gwidget $name
|
||||||
|
pack $name -expand 1 -fill both
|
||||||
|
bind $name <B1-Motion> {
|
||||||
|
::stereo::motion_event %W \
|
||||||
|
[lindex [%W config -width] 4] \
|
||||||
|
[lindex [%W config -height] 4] %x %y
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# This is called when mouse button 1 is pressed and moved
|
||||||
|
proc stereo::motion_event { widget width height x y } {
|
||||||
|
setXrot $widget [expr 360.0 * $y / $height]
|
||||||
|
setYrot $widget [expr 360.0 * ($width - $x) / $width]
|
||||||
|
|
||||||
|
# .sx set [expr 360.0 * $y / $height]
|
||||||
|
# .sy set [expr 360.0 * ($width - $x) / $width]
|
||||||
|
|
||||||
|
.sx set [getXrot]
|
||||||
|
.sy set [getYrot]
|
||||||
|
}
|
||||||
|
|
||||||
|
# This is called when a slider is changed.
|
||||||
|
proc stereo::setAngle {axis value} {
|
||||||
|
# catch because .f.gr might be a label instead of a Togl widget
|
||||||
|
catch {
|
||||||
|
switch -exact $axis {
|
||||||
|
x {setXrot $stereo::gwidget $value}
|
||||||
|
y {setYrot $stereo::gwidget $value}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if { [info script] == $argv0 } {
|
||||||
|
if { $argc == 1 } {
|
||||||
|
set stereo::mode [lindex $argv 0]
|
||||||
|
}
|
||||||
|
::stereo::setup
|
||||||
|
}
|
119
ng/Togl2.1/tclconfig/install-sh
Executable file
119
ng/Togl2.1/tclconfig/install-sh
Executable file
@ -0,0 +1,119 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# install - install a program, script, or datafile
|
||||||
|
# This comes from X11R5; it is not part of GNU.
|
||||||
|
#
|
||||||
|
# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
|
||||||
|
#
|
||||||
|
# This script is compatible with the BSD install script, but was written
|
||||||
|
# from scratch.
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
# set DOITPROG to echo to test this script
|
||||||
|
|
||||||
|
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||||
|
doit="${DOITPROG-}"
|
||||||
|
|
||||||
|
|
||||||
|
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||||
|
|
||||||
|
mvprog="${MVPROG-mv}"
|
||||||
|
cpprog="${CPPROG-cp}"
|
||||||
|
chmodprog="${CHMODPROG-chmod}"
|
||||||
|
chownprog="${CHOWNPROG-chown}"
|
||||||
|
chgrpprog="${CHGRPPROG-chgrp}"
|
||||||
|
stripprog="${STRIPPROG-strip}"
|
||||||
|
rmprog="${RMPROG-rm}"
|
||||||
|
|
||||||
|
instcmd="$mvprog"
|
||||||
|
chmodcmd=""
|
||||||
|
chowncmd=""
|
||||||
|
chgrpcmd=""
|
||||||
|
stripcmd=""
|
||||||
|
rmcmd="$rmprog -f"
|
||||||
|
mvcmd="$mvprog"
|
||||||
|
src=""
|
||||||
|
dst=""
|
||||||
|
|
||||||
|
while [ x"$1" != x ]; do
|
||||||
|
case $1 in
|
||||||
|
-c) instcmd="$cpprog"
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-m) chmodcmd="$chmodprog $2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-o) chowncmd="$chownprog $2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-g) chgrpcmd="$chgrpprog $2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-s) stripcmd="$stripprog"
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
*) if [ x"$src" = x ]
|
||||||
|
then
|
||||||
|
src=$1
|
||||||
|
else
|
||||||
|
dst=$1
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ x"$src" = x ]
|
||||||
|
then
|
||||||
|
echo "install: no input file specified"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ x"$dst" = x ]
|
||||||
|
then
|
||||||
|
echo "install: no destination specified"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# If destination is a directory, append the input filename; if your system
|
||||||
|
# does not like double slashes in filenames, you may need to add some logic
|
||||||
|
|
||||||
|
if [ -d $dst ]
|
||||||
|
then
|
||||||
|
dst="$dst"/`basename $src`
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Make a temp file name in the proper directory.
|
||||||
|
|
||||||
|
dstdir=`dirname $dst`
|
||||||
|
dsttmp=$dstdir/#inst.$$#
|
||||||
|
|
||||||
|
# Move or copy the file name to the temp name
|
||||||
|
|
||||||
|
$doit $instcmd $src $dsttmp
|
||||||
|
|
||||||
|
# and set any options; do chmod last to preserve setuid bits
|
||||||
|
|
||||||
|
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi
|
||||||
|
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi
|
||||||
|
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi
|
||||||
|
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi
|
||||||
|
|
||||||
|
# Now rename the file to the real destination.
|
||||||
|
|
||||||
|
$doit $rmcmd $dst
|
||||||
|
$doit $mvcmd $dsttmp $dst
|
||||||
|
|
||||||
|
|
||||||
|
exit 0
|
4105
ng/Togl2.1/tclconfig/tcl.m4
Normal file
4105
ng/Togl2.1/tclconfig/tcl.m4
Normal file
File diff suppressed because it is too large
Load Diff
663
ng/Togl2.1/texture.c
Normal file
663
ng/Togl2.1/texture.c
Normal file
@ -0,0 +1,663 @@
|
|||||||
|
/* $Id: texture.c,v 1.14 2007/08/03 16:48:50 gregcouch Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl - a Tk OpenGL widget
|
||||||
|
* Copyright (C) 1996-1997 Brian Paul and Ben Bederson
|
||||||
|
* Copyright (C) 2006-2007 Greg Couch
|
||||||
|
* See the LICENSE file for copyright details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* An example Togl program demonstrating texture mapping
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define USE_TOGL_STUBS
|
||||||
|
|
||||||
|
#include "togl.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#if defined(TOGL_AGL)
|
||||||
|
# include <OpenGL/glu.h>
|
||||||
|
#else
|
||||||
|
# include <GL/glu.h>
|
||||||
|
#endif
|
||||||
|
#include "image.h"
|
||||||
|
|
||||||
|
#undef TCL_STORAGE_CLASS
|
||||||
|
#define TCL_STORAGE_CLASS DLLEXPORT
|
||||||
|
|
||||||
|
#define CHECKER 0
|
||||||
|
#define FACE 1
|
||||||
|
#define TREE 2
|
||||||
|
|
||||||
|
|
||||||
|
static GLenum minfilter = GL_NEAREST_MIPMAP_LINEAR;
|
||||||
|
static GLenum magfilter = GL_LINEAR;
|
||||||
|
static GLenum swrap = GL_REPEAT;
|
||||||
|
static GLenum twrap = GL_REPEAT;
|
||||||
|
static GLenum envmode = GL_MODULATE;
|
||||||
|
static GLubyte polycolor[4] = { 255, 255, 255, 255 };
|
||||||
|
static int teximage = CHECKER;
|
||||||
|
static double coord_scale = 1;
|
||||||
|
static double xrot = 0;
|
||||||
|
static double yrot = 0;
|
||||||
|
static double texscale = 1;
|
||||||
|
|
||||||
|
static GLint width, height;
|
||||||
|
|
||||||
|
static GLboolean blend = GL_FALSE;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load a texture image. n is one of CHECKER, FACE or TREE.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
texture_image(int n)
|
||||||
|
{
|
||||||
|
if (n == CHECKER) {
|
||||||
|
#define WIDTH 64
|
||||||
|
#define HEIGHT 64
|
||||||
|
GLubyte teximage[WIDTH * HEIGHT][4];
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
for (i = 0; i < HEIGHT; i++) {
|
||||||
|
for (j = 0; j < WIDTH; j++) {
|
||||||
|
GLubyte value;
|
||||||
|
|
||||||
|
value = ((i / 4 + j / 4) % 2) ? 0xff : 0x00;
|
||||||
|
teximage[i * WIDTH + j][0] = value;
|
||||||
|
teximage[i * WIDTH + j][1] = value;
|
||||||
|
teximage[i * WIDTH + j][2] = value;
|
||||||
|
teximage[i * WIDTH + j][3] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
gluBuild2DMipmaps(GL_TEXTURE_2D, 4, WIDTH, HEIGHT,
|
||||||
|
GL_RGBA, GL_UNSIGNED_BYTE, teximage);
|
||||||
|
blend = GL_FALSE;
|
||||||
|
|
||||||
|
#undef WIDTH
|
||||||
|
#undef HEIGHT
|
||||||
|
} else if (n == FACE) {
|
||||||
|
TK_RGBImageRec *img = tkRGBImageLoad("ben.rgb");
|
||||||
|
|
||||||
|
if (img) {
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
gluBuild2DMipmaps(GL_TEXTURE_2D, img->sizeZ, img->sizeX, img->sizeY,
|
||||||
|
img->sizeZ == 3 ? GL_RGB : GL_RGBA,
|
||||||
|
GL_UNSIGNED_BYTE, img->data);
|
||||||
|
|
||||||
|
blend = GL_TRUE;
|
||||||
|
}
|
||||||
|
} else if (n == TREE) {
|
||||||
|
TK_RGBImageRec *img = tkRGBImageLoad("tree2.rgba");
|
||||||
|
|
||||||
|
if (img) {
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
gluBuild2DMipmaps(GL_TEXTURE_2D, img->sizeZ, img->sizeX, img->sizeY,
|
||||||
|
img->sizeZ == 3 ? GL_RGB : GL_RGBA,
|
||||||
|
GL_UNSIGNED_BYTE, img->data);
|
||||||
|
|
||||||
|
blend = GL_TRUE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl widget create callback. This is called by Tcl/Tk when the widget has
|
||||||
|
* been realized. Here's where one may do some one-time context setup or
|
||||||
|
* initializations.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
create_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
glEnable(GL_DEPTH_TEST); /* Enable depth buffering */
|
||||||
|
|
||||||
|
texture_image(CHECKER);
|
||||||
|
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magfilter);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minfilter);
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl widget reshape callback. This is called by Tcl/Tk when the widget
|
||||||
|
* has been resized. Typically, we call glViewport and perhaps setup the
|
||||||
|
* projection matrix.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
reshape_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
width = Togl_Width(togl);
|
||||||
|
height = Togl_Height(togl);
|
||||||
|
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
check_error(char *where)
|
||||||
|
{
|
||||||
|
GLenum error;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
error = glGetError();
|
||||||
|
if (error == GL_NO_ERROR) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
printf("OpenGL error near %s: %s\n", where, gluErrorString(error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl widget display callback. This is called by Tcl/Tk when the widget's
|
||||||
|
* contents have to be redrawn. Typically, we clear the color and depth
|
||||||
|
* buffers, render our objects, then swap the front/back color buffers.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
display_cb(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
float aspect = (float) width / (float) height;
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 2) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
check_error("begin display\n");
|
||||||
|
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
/* Draw background image */
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
glBegin(GL_POLYGON);
|
||||||
|
glColor3f(0, 0, 0.3f);
|
||||||
|
glVertex2f(-1, -1);
|
||||||
|
glColor3f(0, 0, 0.3f);
|
||||||
|
glVertex2f(1, -1);
|
||||||
|
glColor3f(0, 0, 0.9f);
|
||||||
|
glVertex2f(1, 1);
|
||||||
|
glColor3f(0, 0, 0.9f);
|
||||||
|
glVertex2f(-1, 1);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
/* draw textured object */
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glFrustum(-aspect, aspect, -1, 1, 2, 10);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
glTranslatef(0, 0, -5);
|
||||||
|
glScaled(texscale, texscale, texscale);
|
||||||
|
glRotated(yrot, 0, 1, 0);
|
||||||
|
glRotated(xrot, 1, 0, 0);
|
||||||
|
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glColor4ubv(polycolor);
|
||||||
|
|
||||||
|
if (blend) {
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
}
|
||||||
|
|
||||||
|
glBegin(GL_POLYGON);
|
||||||
|
glTexCoord2f(0, 0);
|
||||||
|
glVertex2f(-1, -1);
|
||||||
|
glTexCoord2d(coord_scale, 0);
|
||||||
|
glVertex2f(1, -1);
|
||||||
|
glTexCoord2d(coord_scale, coord_scale);
|
||||||
|
glVertex2f(1, 1);
|
||||||
|
glTexCoord2d(0, coord_scale);
|
||||||
|
glVertex2f(-1, 1);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
|
Togl_SwapBuffers(togl);
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called when a magnification filter radio button is pressed.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
magfilter_cmd(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
static const char *names[] = { "GL_NEAREST", "GL_LINEAR", NULL };
|
||||||
|
static const GLenum magfilters[] = { GL_NEAREST, GL_LINEAR };
|
||||||
|
int result, index;
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 3) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName magnification-filter-type");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = Tcl_GetIndexFromObj(interp, objv[2], names,
|
||||||
|
"magnification filter type", 0, &index);
|
||||||
|
if (result == TCL_OK) {
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
||||||
|
magfilters[index]);
|
||||||
|
Togl_PostRedisplay(togl);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called when a minification filter radio button is pressed.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
minfilter_cmd(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
static const char *names[] = {
|
||||||
|
"GL_NEAREST", "GL_LINEAR",
|
||||||
|
"GL_NEAREST_MIPMAP_NEAREST", "GL_LINEAR_MIPMAP_NEAREST",
|
||||||
|
"GL_NEAREST_MIPMAP_LINEAR", "GL_LINEAR_MIPMAP_LINEAR", NULL
|
||||||
|
};
|
||||||
|
static const GLenum minfilters[] = {
|
||||||
|
GL_NEAREST, GL_LINEAR,
|
||||||
|
GL_NEAREST_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_NEAREST,
|
||||||
|
GL_NEAREST_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_LINEAR
|
||||||
|
};
|
||||||
|
int result, index;
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 3) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName minification-filter-type");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = Tcl_GetIndexFromObj(interp, objv[2], names,
|
||||||
|
"minification filter type", 0, &index);
|
||||||
|
if (result == TCL_OK) {
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||||
|
minfilters[index]);
|
||||||
|
Togl_PostRedisplay(togl);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
xrot_cmd(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 3) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName angle");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Tcl_GetDoubleFromObj(interp, objv[2], &xrot) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
Togl_PostRedisplay(togl);
|
||||||
|
|
||||||
|
/* Let result string equal value */
|
||||||
|
Tcl_SetObjResult(interp, objv[2]);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
yrot_cmd(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 3) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName angle");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Tcl_GetDoubleFromObj(interp, objv[2], &yrot) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
Togl_PostRedisplay(togl);
|
||||||
|
|
||||||
|
/* Let result string equal value */
|
||||||
|
Tcl_SetObjResult(interp, objv[2]);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
texscale_cmd(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 3) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName value");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Tcl_GetDoubleFromObj(interp, objv[2], &texscale) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
Togl_PostRedisplay(togl);
|
||||||
|
|
||||||
|
/* Let result string equal value */
|
||||||
|
Tcl_SetObjResult(interp, objv[2]);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called when S texture coordinate wrapping is changed.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
swrap_cmd(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
static const char *names[] = { "GL_CLAMP", "GL_REPEAT", NULL };
|
||||||
|
static const GLenum swraps[] = { GL_CLAMP, GL_REPEAT };
|
||||||
|
int result, index;
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 3) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName wrap-mode");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = Tcl_GetIndexFromObj(interp, objv[2], names,
|
||||||
|
"wrap mode", 0, &index);
|
||||||
|
if (result == TCL_OK) {
|
||||||
|
swrap = swraps[index];
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, swrap);
|
||||||
|
Togl_PostRedisplay(togl);
|
||||||
|
/* Let result string equal value */
|
||||||
|
Tcl_SetObjResult(interp, objv[2]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called when T texture coordinate wrapping is changed.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
twrap_cmd(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
static const char *names[] = { "GL_CLAMP", "GL_REPEAT", NULL };
|
||||||
|
static const GLenum twraps[] = { GL_CLAMP, GL_REPEAT };
|
||||||
|
int result, index;
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 3) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName wrap-mode");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = Tcl_GetIndexFromObj(interp, objv[2], names,
|
||||||
|
"wrap mode", 0, &index);
|
||||||
|
if (result == TCL_OK) {
|
||||||
|
twrap = twraps[index];
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, twrap);
|
||||||
|
Togl_PostRedisplay(togl);
|
||||||
|
/* Let result string equal value */
|
||||||
|
Tcl_SetObjResult(interp, objv[2]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called when the texture environment mode is changed.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
envmode_cmd(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
static const char *names[] = {
|
||||||
|
"GL_MODULATE", "GL_DECAL", "GL_BLEND", NULL
|
||||||
|
};
|
||||||
|
static const GLenum envmodes[] = { GL_MODULATE, GL_DECAL, GL_BLEND };
|
||||||
|
int result, index;
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 3) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName texture-env-mode");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = Tcl_GetIndexFromObj(interp, objv[2], names,
|
||||||
|
"texture env mode", 0, &index);
|
||||||
|
if (result == TCL_OK) {
|
||||||
|
envmode = envmodes[index];
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, envmode);
|
||||||
|
Togl_PostRedisplay(togl);
|
||||||
|
/* Let result string equal value */
|
||||||
|
Tcl_SetObjResult(interp, objv[2]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called when the polygon color is changed.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
polycolor_cmd(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
Togl *togl;
|
||||||
|
int r, g, b;
|
||||||
|
|
||||||
|
if (objc != 5) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName r g b");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Tcl_GetIntFromObj(interp, objv[2], &r) != TCL_OK
|
||||||
|
|| Tcl_GetIntFromObj(interp, objv[3], &g) != TCL_OK
|
||||||
|
|| Tcl_GetIntFromObj(interp, objv[4], &b) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
polycolor[0] = r;
|
||||||
|
polycolor[1] = g;
|
||||||
|
polycolor[2] = b;
|
||||||
|
|
||||||
|
Togl_PostRedisplay(togl);
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called when the texture image is to be changed
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
teximage_cmd(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
static const char *names[] = {
|
||||||
|
"CHECKER", "FACE", "TREE", NULL
|
||||||
|
};
|
||||||
|
static const GLenum teximages[] = {
|
||||||
|
CHECKER, FACE, TREE
|
||||||
|
};
|
||||||
|
int result, index;
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 3) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName texture-image-name");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = Tcl_GetIndexFromObj(interp, objv[2], names,
|
||||||
|
"texture image name", 0, &index);
|
||||||
|
if (result == TCL_OK) {
|
||||||
|
teximage = teximages[index];
|
||||||
|
texture_image(teximage);
|
||||||
|
Togl_PostRedisplay(togl);
|
||||||
|
/* Let result string equal value */
|
||||||
|
Tcl_SetObjResult(interp, objv[2]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called when the texture coordinate scale is changed.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
coord_scale_cmd(ClientData clientData, Tcl_Interp *interp, int objc,
|
||||||
|
Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
double s;
|
||||||
|
Togl *togl;
|
||||||
|
|
||||||
|
if (objc != 3) {
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "pathName scale");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Tcl_GetDoubleFromObj(interp, objv[2], &s) != TCL_OK) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
if (s > 0 && s < 10) {
|
||||||
|
coord_scale = s;
|
||||||
|
Togl_PostRedisplay(togl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Let result string equal value */
|
||||||
|
Tcl_SetObjResult(interp, objv[2]);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EXTERN int
|
||||||
|
Texture_Init(Tcl_Interp *interp)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Initialize Tcl and the Togl widget module.
|
||||||
|
*/
|
||||||
|
if (Tcl_InitStubs(interp, "8.1", 0) == NULL
|
||||||
|
|| Togl_InitStubs(interp, "2.0", 0) == NULL) {
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Specify the C callback functions for widget creation, display,
|
||||||
|
* and reshape.
|
||||||
|
*/
|
||||||
|
Tcl_CreateObjCommand(interp, "create_cb", create_cb, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "display_cb", display_cb, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "reshape_cb", reshape_cb, NULL, NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make a new Togl widget command so the Tcl code can set a C variable.
|
||||||
|
*/
|
||||||
|
Tcl_CreateObjCommand(interp, "min_filter", minfilter_cmd, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "mag_filter", magfilter_cmd, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "xrot", xrot_cmd, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "yrot", yrot_cmd, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "texscale", texscale_cmd, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "swrap", swrap_cmd, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "twrap", twrap_cmd, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "envmode", envmode_cmd, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "polycolor", polycolor_cmd, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "teximage", teximage_cmd, NULL, NULL);
|
||||||
|
Tcl_CreateObjCommand(interp, "coord_scale", coord_scale_cmd, NULL, NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Call Tcl_CreateCommand for application-specific commands, if
|
||||||
|
* they weren't already created by the init procedures called above.
|
||||||
|
*/
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
278
ng/Togl2.1/texture.tcl
Normal file
278
ng/Togl2.1/texture.tcl
Normal file
@ -0,0 +1,278 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# the next line restarts using tclsh \
|
||||||
|
exec tclsh "$0" "$@"
|
||||||
|
|
||||||
|
# $Id: texture.tcl,v 1.8 2007/08/03 16:48:50 gregcouch Exp $
|
||||||
|
|
||||||
|
# Togl - a Tk OpenGL widget
|
||||||
|
# Copyright (C) 1996 Brian Paul and Ben Bederson
|
||||||
|
# Copyright (C) 2006-2007 Greg Couch
|
||||||
|
# See the LICENSE file for copyright details.
|
||||||
|
|
||||||
|
|
||||||
|
# Togl texture map demo
|
||||||
|
|
||||||
|
package provide texture 1.0
|
||||||
|
|
||||||
|
# add parent directory to path to find Togl's pkgIndex in current directory
|
||||||
|
if { [file exists pkgIndex.tcl] } {
|
||||||
|
set auto_path [linsert $auto_path 0 ..]
|
||||||
|
}
|
||||||
|
# following load also loads Tk and Togl packages
|
||||||
|
load [file dirname [info script]]/texture[info sharedlibextension]
|
||||||
|
|
||||||
|
# create ::texture namespace
|
||||||
|
namespace eval ::texture {
|
||||||
|
}
|
||||||
|
|
||||||
|
# Called magnification filter changes
|
||||||
|
proc ::texture::new_magfilter {} {
|
||||||
|
global magfilter
|
||||||
|
mag_filter .f1.view $magfilter
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Called minification filter changes
|
||||||
|
proc ::texture::new_minfilter {} {
|
||||||
|
global minfilter
|
||||||
|
min_filter .f1.view $minfilter
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Called when texture image radio button changes
|
||||||
|
proc ::texture::new_image {} {
|
||||||
|
global image
|
||||||
|
teximage .f1.view $image
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Called when texture S wrap button changes
|
||||||
|
proc ::texture::new_swrap {} {
|
||||||
|
global swrap
|
||||||
|
swrap .f1.view $swrap
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Called when texture T wrap button changes
|
||||||
|
proc ::texture::new_twrap {} {
|
||||||
|
global twrap
|
||||||
|
twrap .f1.view $twrap
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Called when texture environment radio button selected
|
||||||
|
proc ::texture::new_env {} {
|
||||||
|
global envmode
|
||||||
|
envmode .f1.view $envmode
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Called when polygon color sliders change
|
||||||
|
proc ::texture::new_color { foo } {
|
||||||
|
global poly_red poly_green poly_blue
|
||||||
|
polycolor .f1.view $poly_red $poly_green $poly_blue
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
proc ::texture::new_coord_scale { name element op } {
|
||||||
|
global coord_scale
|
||||||
|
coord_scale .f1.view $coord_scale
|
||||||
|
}
|
||||||
|
|
||||||
|
proc ::texture::take_photo {} {
|
||||||
|
image create photo teximg
|
||||||
|
.f1.view takephoto teximg
|
||||||
|
teximg write image.ppm -format ppm
|
||||||
|
}
|
||||||
|
|
||||||
|
# Make the widgets
|
||||||
|
proc ::texture::setup {} {
|
||||||
|
global magfilter
|
||||||
|
global minfilter
|
||||||
|
global image
|
||||||
|
global swrap
|
||||||
|
global twrap
|
||||||
|
global envmode
|
||||||
|
global poly_red
|
||||||
|
global poly_green
|
||||||
|
global poly_blue
|
||||||
|
global coord_scale
|
||||||
|
global startx starty # location of mouse when button pressed
|
||||||
|
global xangle yangle
|
||||||
|
global xangle0 yangle0
|
||||||
|
global texscale texscale0
|
||||||
|
|
||||||
|
wm title . "Texture Map Options"
|
||||||
|
|
||||||
|
### Two frames: top half and bottom half
|
||||||
|
frame .f1
|
||||||
|
frame .f2
|
||||||
|
|
||||||
|
### The OpenGL window
|
||||||
|
togl .f1.view -width 250 -height 250 -rgba true -double true -depth true -create create_cb -reshape reshape_cb -display display_cb
|
||||||
|
|
||||||
|
|
||||||
|
### Filter radio buttons
|
||||||
|
frame .f1.filter -relief ridge -borderwidth 3
|
||||||
|
|
||||||
|
frame .f1.filter.mag -relief ridge -borderwidth 2
|
||||||
|
|
||||||
|
label .f1.filter.mag.label -text "Magnification Filter" -anchor w
|
||||||
|
radiobutton .f1.filter.mag.nearest -text GL_NEAREST -anchor w -variable magfilter -value GL_NEAREST -command ::texture::new_magfilter
|
||||||
|
radiobutton .f1.filter.mag.linear -text GL_LINEAR -anchor w -variable magfilter -value GL_LINEAR -command ::texture::new_magfilter
|
||||||
|
|
||||||
|
frame .f1.filter.min -relief ridge -borderwidth 2
|
||||||
|
|
||||||
|
label .f1.filter.min.label -text "Minification Filter" -anchor w
|
||||||
|
radiobutton .f1.filter.min.nearest -text GL_NEAREST -anchor w -variable minfilter -value GL_NEAREST -command ::texture::new_minfilter
|
||||||
|
radiobutton .f1.filter.min.linear -text GL_LINEAR -anchor w -variable minfilter -value GL_LINEAR -command ::texture::new_minfilter
|
||||||
|
radiobutton .f1.filter.min.nearest_mipmap_nearest -text GL_NEAREST_MIPMAP_NEAREST -anchor w -variable minfilter -value GL_NEAREST_MIPMAP_NEAREST -command ::texture::new_minfilter
|
||||||
|
radiobutton .f1.filter.min.linear_mipmap_nearest -text GL_LINEAR_MIPMAP_NEAREST -anchor w -variable minfilter -value GL_LINEAR_MIPMAP_NEAREST -command ::texture::new_minfilter
|
||||||
|
radiobutton .f1.filter.min.nearest_mipmap_linear -text GL_NEAREST_MIPMAP_LINEAR -anchor w -variable minfilter -value GL_NEAREST_MIPMAP_LINEAR -command ::texture::new_minfilter
|
||||||
|
radiobutton .f1.filter.min.linear_mipmap_linear -text GL_LINEAR_MIPMAP_LINEAR -anchor w -variable minfilter -value GL_LINEAR_MIPMAP_LINEAR -command ::texture::new_minfilter
|
||||||
|
|
||||||
|
pack .f1.filter.mag -fill x
|
||||||
|
pack .f1.filter.mag.label -fill x
|
||||||
|
pack .f1.filter.mag.nearest -side top -fill x
|
||||||
|
pack .f1.filter.mag.linear -side top -fill x
|
||||||
|
|
||||||
|
pack .f1.filter.min -fill both -expand true
|
||||||
|
pack .f1.filter.min.label -side top -fill x
|
||||||
|
pack .f1.filter.min.nearest -side top -fill x
|
||||||
|
pack .f1.filter.min.linear -side top -fill x
|
||||||
|
pack .f1.filter.min.nearest_mipmap_nearest -side top -fill x
|
||||||
|
pack .f1.filter.min.linear_mipmap_nearest -side top -fill x
|
||||||
|
pack .f1.filter.min.nearest_mipmap_linear -side top -fill x
|
||||||
|
pack .f1.filter.min.linear_mipmap_linear -side top -fill x
|
||||||
|
|
||||||
|
|
||||||
|
### Texture coordinate scale and wrapping
|
||||||
|
frame .f2.coord -relief ridge -borderwidth 3
|
||||||
|
frame .f2.coord.scale -relief ridge -borderwidth 2
|
||||||
|
label .f2.coord.scale.label -text "Max Texture Coord" -anchor w
|
||||||
|
entry .f2.coord.scale.entry -textvariable coord_scale
|
||||||
|
trace variable coord_scale w ::texture::new_coord_scale
|
||||||
|
|
||||||
|
frame .f2.coord.s -relief ridge -borderwidth 2
|
||||||
|
label .f2.coord.s.label -text "GL_TEXTURE_WRAP_S" -anchor w
|
||||||
|
radiobutton .f2.coord.s.repeat -text "GL_REPEAT" -anchor w -variable swrap -value GL_REPEAT -command ::texture::new_swrap
|
||||||
|
radiobutton .f2.coord.s.clamp -text "GL_CLAMP" -anchor w -variable swrap -value GL_CLAMP -command ::texture::new_swrap
|
||||||
|
|
||||||
|
frame .f2.coord.t -relief ridge -borderwidth 2
|
||||||
|
label .f2.coord.t.label -text "GL_TEXTURE_WRAP_T" -anchor w
|
||||||
|
radiobutton .f2.coord.t.repeat -text "GL_REPEAT" -anchor w -variable twrap -value GL_REPEAT -command ::texture::new_twrap
|
||||||
|
radiobutton .f2.coord.t.clamp -text "GL_CLAMP" -anchor w -variable twrap -value GL_CLAMP -command ::texture::new_twrap
|
||||||
|
|
||||||
|
pack .f2.coord.scale -fill both -expand true
|
||||||
|
pack .f2.coord.scale.label -side top -fill x
|
||||||
|
pack .f2.coord.scale.entry -side top -fill x
|
||||||
|
|
||||||
|
pack .f2.coord.s -fill x
|
||||||
|
pack .f2.coord.s.label -side top -fill x
|
||||||
|
pack .f2.coord.s.repeat -side top -fill x
|
||||||
|
pack .f2.coord.s.clamp -side top -fill x
|
||||||
|
|
||||||
|
pack .f2.coord.t -fill x
|
||||||
|
pack .f2.coord.t.label -side top -fill x
|
||||||
|
pack .f2.coord.t.repeat -side top -fill x
|
||||||
|
pack .f2.coord.t.clamp -side top -fill x
|
||||||
|
|
||||||
|
|
||||||
|
### Texture image radio buttons (just happens to fit into the coord frame)
|
||||||
|
frame .f2.env -relief ridge -borderwidth 3
|
||||||
|
frame .f2.env.image -relief ridge -borderwidth 2
|
||||||
|
label .f2.env.image.label -text "Texture Image" -anchor w
|
||||||
|
radiobutton .f2.env.image.checker -text "Checker" -anchor w -variable image -value CHECKER -command ::texture::new_image
|
||||||
|
radiobutton .f2.env.image.tree -text "Tree" -anchor w -variable image -value TREE -command ::texture::new_image
|
||||||
|
radiobutton .f2.env.image.face -text "Face" -anchor w -variable image -value FACE -command ::texture::new_image
|
||||||
|
pack .f2.env.image -fill x
|
||||||
|
pack .f2.env.image.label -side top -fill x
|
||||||
|
pack .f2.env.image.checker -side top -fill x
|
||||||
|
pack .f2.env.image.tree -side top -fill x
|
||||||
|
pack .f2.env.image.face -side top -fill x
|
||||||
|
|
||||||
|
|
||||||
|
### Texture Environment
|
||||||
|
label .f2.env.label -text "GL_TEXTURE_ENV_MODE" -anchor w
|
||||||
|
radiobutton .f2.env.modulate -text "GL_MODULATE" -anchor w -variable envmode -value GL_MODULATE -command ::texture::new_env
|
||||||
|
radiobutton .f2.env.decal -text "GL_DECAL" -anchor w -variable envmode -value GL_DECAL -command ::texture::new_env
|
||||||
|
radiobutton .f2.env.blend -text "GL_BLEND" -anchor w -variable envmode -value GL_BLEND -command ::texture::new_env
|
||||||
|
pack .f2.env.label -fill x
|
||||||
|
pack .f2.env.modulate -side top -fill x
|
||||||
|
pack .f2.env.decal -side top -fill x
|
||||||
|
pack .f2.env.blend -side top -fill x
|
||||||
|
|
||||||
|
### Polygon color
|
||||||
|
frame .f2.color -relief ridge -borderwidth 3
|
||||||
|
label .f2.color.label -text "Polygon color" -anchor w
|
||||||
|
scale .f2.color.red -label Red -from 0 -to 255 -orient horizontal -variable poly_red -command ::texture::new_color
|
||||||
|
scale .f2.color.green -label Green -from 0 -to 255 -orient horizontal -variable poly_green -command ::texture::new_color
|
||||||
|
scale .f2.color.blue -label Blue -from 0 -to 255 -orient horizontal -variable poly_blue -command ::texture::new_color
|
||||||
|
pack .f2.color.label -fill x
|
||||||
|
pack .f2.color.red -side top -fill x
|
||||||
|
pack .f2.color.green -side top -fill x
|
||||||
|
pack .f2.color.blue -side top -fill x
|
||||||
|
|
||||||
|
|
||||||
|
### Main widgets
|
||||||
|
pack .f1.view -side left -fill both -expand true
|
||||||
|
pack .f1.filter -side left -fill y
|
||||||
|
pack .f1 -side top -fill both -expand true
|
||||||
|
|
||||||
|
pack .f2.coord .f2.env -side left -fill both
|
||||||
|
pack .f2.color -fill x
|
||||||
|
pack .f2 -side top -fill x
|
||||||
|
|
||||||
|
button .photo -text "Take Photo" -command ::texture::take_photo
|
||||||
|
pack .photo -expand true -fill both
|
||||||
|
button .quit -text Quit -command exit
|
||||||
|
pack .quit -expand true -fill both
|
||||||
|
|
||||||
|
bind .f1.view <ButtonPress-1> {
|
||||||
|
set startx %x
|
||||||
|
set starty %y
|
||||||
|
set xangle0 $xangle
|
||||||
|
set yangle0 $yangle
|
||||||
|
}
|
||||||
|
|
||||||
|
bind .f1.view <B1-Motion> {
|
||||||
|
set xangle [expr $xangle0 + (%x - $startx) / 3.0 ]
|
||||||
|
set yangle [expr $yangle0 + (%y - $starty) / 3.0 ]
|
||||||
|
yrot .f1.view $xangle
|
||||||
|
xrot .f1.view $yangle
|
||||||
|
}
|
||||||
|
|
||||||
|
bind .f1.view <ButtonPress-2> {
|
||||||
|
set startx %x
|
||||||
|
set starty %y
|
||||||
|
set texscale0 $texscale
|
||||||
|
}
|
||||||
|
|
||||||
|
bind .f1.view <B2-Motion> {
|
||||||
|
set q [ expr ($starty - %y) / 400.0 ]
|
||||||
|
set texscale [expr $texscale0 * exp($q)]
|
||||||
|
texscale .f1.view $texscale
|
||||||
|
}
|
||||||
|
|
||||||
|
# set default values:
|
||||||
|
set minfilter GL_NEAREST_MIPMAP_LINEAR
|
||||||
|
set magfilter GL_LINEAR
|
||||||
|
set swrap GL_REPEAT
|
||||||
|
set twrap GL_REPEAT
|
||||||
|
set envmode GL_MODULATE
|
||||||
|
set image CHECKER
|
||||||
|
set poly_red 255
|
||||||
|
set poly_green 255
|
||||||
|
set poly_blue 255
|
||||||
|
set coord_scale 1.0
|
||||||
|
|
||||||
|
set xangle 0.0
|
||||||
|
set yangle 0.0
|
||||||
|
set texscale 1.0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Execution starts here!
|
||||||
|
if { [info script] == $argv0 } {
|
||||||
|
::texture::setup
|
||||||
|
}
|
5405
ng/Togl2.1/togl.c
Normal file
5405
ng/Togl2.1/togl.c
Normal file
File diff suppressed because it is too large
Load Diff
195
ng/Togl2.1/togl.decls
Normal file
195
ng/Togl2.1/togl.decls
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
library togl
|
||||||
|
interface togl
|
||||||
|
|
||||||
|
# Declare each of the functions in the public Togl interface. Note that
|
||||||
|
# the an index should never be reused for a different function in order
|
||||||
|
# to preserve backwards compatibility.
|
||||||
|
|
||||||
|
# package initialization
|
||||||
|
declare 0 generic {
|
||||||
|
int Togl_Init(Tcl_Interp *interp)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Miscellaneous
|
||||||
|
declare 1 generic {
|
||||||
|
void Togl_MakeCurrent(const Togl *togl)
|
||||||
|
}
|
||||||
|
declare 2 generic {
|
||||||
|
void Togl_PostRedisplay(Togl *togl)
|
||||||
|
}
|
||||||
|
declare 3 generic {
|
||||||
|
void Togl_SwapBuffers(const Togl *togl)
|
||||||
|
}
|
||||||
|
declare 33 generic {
|
||||||
|
Bool Togl_SwapInterval(const Togl *togl, int interval)
|
||||||
|
}
|
||||||
|
declare 48 generic {
|
||||||
|
int Togl_CopyContext(const Togl *from, const Togl *to, unsigned int mask)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Query functions
|
||||||
|
declare 4 generic {
|
||||||
|
const char *Togl_Ident(const Togl *togl)
|
||||||
|
}
|
||||||
|
declare 5 generic {
|
||||||
|
int Togl_Width(const Togl *togl)
|
||||||
|
}
|
||||||
|
declare 6 generic {
|
||||||
|
int Togl_Height(const Togl *togl)
|
||||||
|
}
|
||||||
|
declare 7 generic {
|
||||||
|
Tcl_Interp *Togl_Interp(const Togl *togl)
|
||||||
|
}
|
||||||
|
declare 8 generic {
|
||||||
|
Tk_Window Togl_TkWin(const Togl *togl)
|
||||||
|
}
|
||||||
|
declare 9 generic {
|
||||||
|
const char *Togl_CommandName(const Togl *togl)
|
||||||
|
}
|
||||||
|
declare 36 generic {
|
||||||
|
int Togl_ContextTag(const Togl *togl)
|
||||||
|
}
|
||||||
|
declare 37 generic {
|
||||||
|
Bool Togl_UpdatePending(const Togl *togl)
|
||||||
|
}
|
||||||
|
|
||||||
|
declare 40 generic {
|
||||||
|
Bool Togl_HasRGBA(const Togl *togl)
|
||||||
|
}
|
||||||
|
|
||||||
|
declare 41 generic {
|
||||||
|
Bool Togl_IsDoubleBuffered(const Togl *togl)
|
||||||
|
}
|
||||||
|
|
||||||
|
declare 42 generic {
|
||||||
|
Bool Togl_HasDepthBuffer(const Togl *togl)
|
||||||
|
}
|
||||||
|
|
||||||
|
declare 43 generic {
|
||||||
|
Bool Togl_HasAccumulationBuffer(const Togl *togl)
|
||||||
|
}
|
||||||
|
|
||||||
|
declare 44 generic {
|
||||||
|
Bool Togl_HasDestinationAlpha(const Togl *togl)
|
||||||
|
}
|
||||||
|
|
||||||
|
declare 45 generic {
|
||||||
|
Bool Togl_HasStencilBuffer(const Togl *togl)
|
||||||
|
}
|
||||||
|
|
||||||
|
declare 46 generic {
|
||||||
|
int Togl_StereoMode(const Togl *togl)
|
||||||
|
}
|
||||||
|
|
||||||
|
declare 47 generic {
|
||||||
|
Bool Togl_HasMultisample(const Togl *togl)
|
||||||
|
}
|
||||||
|
|
||||||
|
declare 49 generic {
|
||||||
|
int Togl_PixelScale(const Togl *togl)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Color Index mode
|
||||||
|
declare 10 generic {
|
||||||
|
unsigned long Togl_AllocColor(const Togl *togl, float red,
|
||||||
|
float green, float blue)
|
||||||
|
}
|
||||||
|
declare 11 generic {
|
||||||
|
void Togl_FreeColor(const Togl *togl, unsigned long index)
|
||||||
|
}
|
||||||
|
declare 12 generic {
|
||||||
|
void Togl_SetColor(const Togl *togl, unsigned long index,
|
||||||
|
float red, float green, float blue)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Bitmap fonts
|
||||||
|
declare 13 generic {
|
||||||
|
Tcl_Obj *Togl_LoadBitmapFont(const Togl *togl, const char *fontname)
|
||||||
|
}
|
||||||
|
declare 14 generic {
|
||||||
|
int Togl_UnloadBitmapFont(const Togl *togl, Tcl_Obj *toglfont)
|
||||||
|
}
|
||||||
|
|
||||||
|
declare 38 generic {
|
||||||
|
int Togl_WriteObj(const Togl *togl, const Tcl_Obj *toglfont, Tcl_Obj *obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
declare 39 generic {
|
||||||
|
int Togl_WriteChars(const Togl *togl, const Tcl_Obj *toglfont, const char *str, int len)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Overlay functions
|
||||||
|
declare 15 generic {
|
||||||
|
void Togl_UseLayer(Togl *togl, int layer)
|
||||||
|
}
|
||||||
|
declare 16 generic {
|
||||||
|
void Togl_ShowOverlay(Togl *togl)
|
||||||
|
}
|
||||||
|
declare 17 generic {
|
||||||
|
void Togl_HideOverlay(Togl *togl)
|
||||||
|
}
|
||||||
|
declare 18 generic {
|
||||||
|
void Togl_PostOverlayRedisplay(Togl *togl)
|
||||||
|
}
|
||||||
|
declare 19 generic {
|
||||||
|
int Togl_ExistsOverlay(const Togl *togl)
|
||||||
|
}
|
||||||
|
declare 20 generic {
|
||||||
|
int Togl_GetOverlayTransparentValue(const Togl *togl)
|
||||||
|
}
|
||||||
|
declare 21 generic {
|
||||||
|
int Togl_IsMappedOverlay(const Togl *togl)
|
||||||
|
}
|
||||||
|
declare 22 generic {
|
||||||
|
unsigned long Togl_AllocColorOverlay(const Togl *togl,
|
||||||
|
float red, float green, float blue)
|
||||||
|
}
|
||||||
|
declare 23 generic {
|
||||||
|
void Togl_FreeColorOverlay(const Togl *togl, unsigned long index)
|
||||||
|
}
|
||||||
|
|
||||||
|
# User client data
|
||||||
|
declare 24 generic {
|
||||||
|
ClientData Togl_GetClientData(const Togl *togl)
|
||||||
|
}
|
||||||
|
declare 25 generic {
|
||||||
|
void Togl_SetClientData(Togl *togl, ClientData clientData)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Stereo support
|
||||||
|
declare 26 generic {
|
||||||
|
void Togl_DrawBuffer(Togl *togl, GLenum mode)
|
||||||
|
}
|
||||||
|
declare 27 generic {
|
||||||
|
void Togl_Clear(const Togl *togl, GLbitfield mask)
|
||||||
|
}
|
||||||
|
declare 28 generic {
|
||||||
|
void Togl_Frustum(const Togl *togl, GLdouble left, GLdouble right,
|
||||||
|
GLdouble bottom, GLdouble top, GLdouble near, GLdouble far)
|
||||||
|
}
|
||||||
|
declare 34 generic {
|
||||||
|
void Togl_Ortho(const Togl *togl, GLdouble left, GLdouble right,
|
||||||
|
GLdouble bottom, GLdouble top, GLdouble near, GLdouble far)
|
||||||
|
}
|
||||||
|
declare 35 generic {
|
||||||
|
int Togl_NumEyes(const Togl *togl)
|
||||||
|
}
|
||||||
|
|
||||||
|
# save current contents of OpenGL window into photo image
|
||||||
|
declare 30 generic {
|
||||||
|
int Togl_TakePhoto(Togl *togl, Tk_PhotoHandle photo)
|
||||||
|
}
|
||||||
|
|
||||||
|
# platform-independent lookup of OpenGL functions
|
||||||
|
declare 31 generic {
|
||||||
|
Togl_FuncPtr Togl_GetProcAddr(const char *funcname)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Return the Togl data associated with pathName
|
||||||
|
declare 29 generic {
|
||||||
|
int Togl_GetToglFromObj(Tcl_Interp *interp, Tcl_Obj *obj, Togl **toglPtr)
|
||||||
|
}
|
||||||
|
declare 32 generic {
|
||||||
|
int Togl_GetToglFromName(Tcl_Interp *interp, const char *cmdName, Togl **toglPtr)
|
||||||
|
}
|
145
ng/Togl2.1/togl.h
Normal file
145
ng/Togl2.1/togl.h
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
/* $Id: togl.h,v 1.39 2009/03/31 23:21:13 gregcouch Exp $ */
|
||||||
|
|
||||||
|
/* vi:set sw=4: */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl - a Tk OpenGL widget
|
||||||
|
*
|
||||||
|
* Copyright (C) 1996-2002 Brian Paul and Ben Bederson
|
||||||
|
* Copyright (C) 2005-2009 Greg Couch
|
||||||
|
* See the LICENSE file for copyright details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef TOGL_H
|
||||||
|
# define TOGL_H
|
||||||
|
|
||||||
|
//# include "togl_ws.h"
|
||||||
|
|
||||||
|
# ifdef TOGL_WGL
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# include <windows.h>
|
||||||
|
# undef WIN32_LEAN_AND_MEAN
|
||||||
|
# if defined(_MSC_VER)
|
||||||
|
# define DllEntryPoint DllMain
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if defined(TOGL_AGL) || defined(TOGL_NSOPENGL)
|
||||||
|
# ifndef MAC_OSX_TCL
|
||||||
|
# define MAC_OSX_TCL 1
|
||||||
|
# endif
|
||||||
|
# ifndef MAC_OSX_TK
|
||||||
|
# define MAC_OSX_TK 1
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef USE_TOGL_STUBS
|
||||||
|
# ifndef USE_TCL_STUBS
|
||||||
|
# define USE_TCL_STUBS
|
||||||
|
# endif
|
||||||
|
# ifndef USE_TK_STUBS
|
||||||
|
# define USE_TK_STUBS
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# include <tcl.h>
|
||||||
|
# include <tk.h>
|
||||||
|
# if defined(TOGL_AGL)
|
||||||
|
# include <OpenGL/gl.h>
|
||||||
|
# elif defined(TOGL_NSOPENGL)
|
||||||
|
# include <OpenGL/OpenGL.h>
|
||||||
|
# include <OpenGL/gl.h>
|
||||||
|
# else
|
||||||
|
# include <GL/gl.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef BUILD_togl
|
||||||
|
# undef TCL_STORAGE_CLASS
|
||||||
|
# define TCL_STORAGE_CLASS DLLEXPORT
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef CONST84
|
||||||
|
# define CONST84
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef NULL
|
||||||
|
# define NULL 0
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef EXTERN
|
||||||
|
# define EXTERN extern
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
/* *INDENT-OFF* */
|
||||||
|
extern "C" {
|
||||||
|
/* *INDENT-ON* */
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define TOGL_VERSION "2.1"
|
||||||
|
# define TOGL_MAJOR_VERSION 2
|
||||||
|
# define TOGL_MINOR_VERSION 1
|
||||||
|
|
||||||
|
/*
|
||||||
|
* "Standard" fonts which can be specified to Togl_LoadBitmapFont()
|
||||||
|
* Deprecated. Use the Tk font name or description instead.
|
||||||
|
*/
|
||||||
|
# define TOGL_BITMAP_8_BY_13 "8x13"
|
||||||
|
# define TOGL_BITMAP_9_BY_15 "9x15"
|
||||||
|
# define TOGL_BITMAP_TIMES_ROMAN_10 "Times 10"
|
||||||
|
# define TOGL_BITMAP_TIMES_ROMAN_24 "Times 24"
|
||||||
|
# define TOGL_BITMAP_HELVETICA_10 "Helvetica 10"
|
||||||
|
# define TOGL_BITMAP_HELVETICA_12 "Helvetica 12"
|
||||||
|
# define TOGL_BITMAP_HELVETICA_18 "Helvetica 18"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Normal and overlay plane constants
|
||||||
|
*/
|
||||||
|
# define TOGL_NORMAL 1
|
||||||
|
# define TOGL_OVERLAY 2
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stereo techniques:
|
||||||
|
* Only the native method uses OpenGL quad-buffered stereo.
|
||||||
|
* All need the eye offset and eye distance set properly.
|
||||||
|
*/
|
||||||
|
/* These versions need one eye drawn */
|
||||||
|
# define TOGL_STEREO_NONE 0
|
||||||
|
# define TOGL_STEREO_LEFT_EYE 1 /* just the left eye */
|
||||||
|
# define TOGL_STEREO_RIGHT_EYE 2 /* just the right eye */
|
||||||
|
# define TOGL_STEREO_ONE_EYE_MAX 127
|
||||||
|
/* These versions need both eyes drawn */
|
||||||
|
# define TOGL_STEREO_NATIVE 128
|
||||||
|
# define TOGL_STEREO_SGIOLDSTYLE 129 /* interlaced, SGI API */
|
||||||
|
# define TOGL_STEREO_ANAGLYPH 130
|
||||||
|
# define TOGL_STEREO_CROSS_EYE 131
|
||||||
|
# define TOGL_STEREO_WALL_EYE 132
|
||||||
|
# define TOGL_STEREO_DTI 133 /* dti3d.com */
|
||||||
|
# define TOGL_STEREO_ROW_INTERLEAVED 134 /* www.vrex.com/developer/interleave.htm */
|
||||||
|
|
||||||
|
struct Togl;
|
||||||
|
typedef struct Togl Togl;
|
||||||
|
typedef void (*Togl_FuncPtr) ();
|
||||||
|
|
||||||
|
const char *Togl_InitStubs _ANSI_ARGS_((Tcl_Interp *interp, const char *version,
|
||||||
|
int exact));
|
||||||
|
|
||||||
|
# ifndef USE_TOGL_STUBS
|
||||||
|
# define Togl_InitStubs(interp, version, exact) \
|
||||||
|
Tcl_PkgRequire(interp, "Togl", version, exact)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Platform independent exported functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
# include "toglDecls.h"
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
/* *INDENT-OFF* */
|
||||||
|
}
|
||||||
|
/* *INDENT-ON* */
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#endif
|
293
ng/Togl2.1/toglAGL.c
Normal file
293
ng/Togl2.1/toglAGL.c
Normal file
@ -0,0 +1,293 @@
|
|||||||
|
/* $Id: toglAGL.c,v 1.7 2009/10/22 00:06:41 gregcouch Exp $ */
|
||||||
|
|
||||||
|
/* vi:set sw=4 expandtab: */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl - a Tk OpenGL widget
|
||||||
|
*
|
||||||
|
* Copyright (C) 1996-2002 Brian Paul and Ben Bederson
|
||||||
|
* Copyright (C) 2005-2009 Greg Couch
|
||||||
|
* See the LICENSE file for copyright details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct FBInfo
|
||||||
|
{
|
||||||
|
GLint acceleration;
|
||||||
|
GLint colors;
|
||||||
|
GLint depth;
|
||||||
|
GLint samples;
|
||||||
|
AGLPixelFormat pix;
|
||||||
|
};
|
||||||
|
typedef struct FBInfo FBInfo;
|
||||||
|
|
||||||
|
static int
|
||||||
|
FBInfoCmp(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* 1. full acceleration is better
|
||||||
|
* 2. greater color bits is better
|
||||||
|
* 3. greater depth bits is better
|
||||||
|
* 4. more multisampling is better
|
||||||
|
*/
|
||||||
|
const FBInfo *x = (const FBInfo *) a;
|
||||||
|
const FBInfo *y = (const FBInfo *) b;
|
||||||
|
|
||||||
|
if (x->acceleration != y->acceleration)
|
||||||
|
return y->acceleration - x->acceleration;
|
||||||
|
if (x->colors != y->colors)
|
||||||
|
return y->colors - x->colors;
|
||||||
|
if (x->depth != y->depth)
|
||||||
|
return y->depth - x->depth;
|
||||||
|
if (x->samples != y->samples)
|
||||||
|
return y->samples - x->samples;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static AGLPixelFormat
|
||||||
|
togl_pixelFormat(Togl *togl)
|
||||||
|
{
|
||||||
|
GLint attribs[32];
|
||||||
|
int na = 0;
|
||||||
|
AGLPixelFormat pix;
|
||||||
|
GDHandle display = NULL;
|
||||||
|
FBInfo *info = NULL;
|
||||||
|
int count;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (togl->MultisampleFlag && !hasMultisampling) {
|
||||||
|
Tcl_SetResult(togl->Interp,
|
||||||
|
TCL_STUPID "multisampling not supported", TCL_STATIC);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (togl->PbufferFlag && !togl->RgbaFlag) {
|
||||||
|
Tcl_SetResult(togl->Interp,
|
||||||
|
TCL_STUPID "puffer must be RGB[A]", TCL_STATIC);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
attribs[na++] = AGL_MINIMUM_POLICY;
|
||||||
|
/* ask for hardware-accelerated onscreen */
|
||||||
|
attribs[na++] = AGL_ACCELERATED;
|
||||||
|
attribs[na++] = AGL_NO_RECOVERY;
|
||||||
|
if (togl->RgbaFlag) {
|
||||||
|
/* RGB[A] mode */
|
||||||
|
attribs[na++] = AGL_RGBA;
|
||||||
|
attribs[na++] = AGL_RED_SIZE;
|
||||||
|
attribs[na++] = togl->RgbaRed;
|
||||||
|
attribs[na++] = AGL_GREEN_SIZE;
|
||||||
|
attribs[na++] = togl->RgbaGreen;
|
||||||
|
attribs[na++] = AGL_BLUE_SIZE;
|
||||||
|
attribs[na++] = togl->RgbaBlue;
|
||||||
|
if (togl->AlphaFlag) {
|
||||||
|
attribs[na++] = AGL_ALPHA_SIZE;
|
||||||
|
attribs[na++] = togl->AlphaSize;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Color index mode */
|
||||||
|
attribs[na++] = AGL_BUFFER_SIZE;
|
||||||
|
attribs[na++] = 8;
|
||||||
|
}
|
||||||
|
if (togl->DepthFlag) {
|
||||||
|
attribs[na++] = AGL_DEPTH_SIZE;
|
||||||
|
attribs[na++] = togl->DepthSize;
|
||||||
|
}
|
||||||
|
if (togl->DoubleFlag) {
|
||||||
|
attribs[na++] = AGL_DOUBLEBUFFER;
|
||||||
|
}
|
||||||
|
if (togl->StencilFlag) {
|
||||||
|
attribs[na++] = AGL_STENCIL_SIZE;
|
||||||
|
attribs[na++] = togl->StencilSize;
|
||||||
|
}
|
||||||
|
if (togl->AccumFlag) {
|
||||||
|
attribs[na++] = AGL_ACCUM_RED_SIZE;
|
||||||
|
attribs[na++] = togl->AccumRed;
|
||||||
|
attribs[na++] = AGL_ACCUM_GREEN_SIZE;
|
||||||
|
attribs[na++] = togl->AccumGreen;
|
||||||
|
attribs[na++] = AGL_ACCUM_BLUE_SIZE;
|
||||||
|
attribs[na++] = togl->AccumBlue;
|
||||||
|
if (togl->AlphaFlag) {
|
||||||
|
attribs[na++] = AGL_ACCUM_ALPHA_SIZE;
|
||||||
|
attribs[na++] = togl->AccumAlpha;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (togl->MultisampleFlag) {
|
||||||
|
attribs[na++] = AGL_MULTISAMPLE;
|
||||||
|
#ifdef AGL_SAMPLES_ARB
|
||||||
|
/* OS X 10.2 and later */
|
||||||
|
attribs[na++] = AGL_SAMPLE_BUFFERS_ARB;
|
||||||
|
attribs[na++] = 1;
|
||||||
|
attribs[na++] = AGL_SAMPLES_ARB;
|
||||||
|
attribs[na++] = 2;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (togl->AuxNumber != 0) {
|
||||||
|
attribs[na++] = AGL_AUX_BUFFERS;
|
||||||
|
attribs[na++] = togl->AuxNumber;
|
||||||
|
}
|
||||||
|
if (togl->Stereo == TOGL_STEREO_NATIVE) {
|
||||||
|
attribs[na++] = AGL_STEREO;
|
||||||
|
}
|
||||||
|
if (togl->FullscreenFlag) {
|
||||||
|
attribs[na++] = AGL_FULLSCREEN;
|
||||||
|
/* TODO: convert Tk screen to display device */
|
||||||
|
display = GetMainDevice();
|
||||||
|
}
|
||||||
|
attribs[na++] = AGL_NONE;
|
||||||
|
|
||||||
|
if ((pix = aglChoosePixelFormat(&display, togl->FullscreenFlag ? 1 : 0,
|
||||||
|
attribs)) == NULL) {
|
||||||
|
Tcl_SetResult(togl->Interp, TCL_STUPID "couldn't choose pixel format",
|
||||||
|
TCL_STATIC);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TODO: since we aglDestroyPixelFormat elsewhere, this code may leak
|
||||||
|
* memory if the pixel format choosen is not the original (because
|
||||||
|
* aglDestroyPixelFormat will give an error). */
|
||||||
|
count = 0;
|
||||||
|
do {
|
||||||
|
info = (FBInfo *) realloc(info, (count + 1) * sizeof (FBInfo));
|
||||||
|
info[count].pix = pix;
|
||||||
|
aglDescribePixelFormat(pix, AGL_ACCELERATED, &info[count].acceleration);
|
||||||
|
aglDescribePixelFormat(pix, AGL_BUFFER_SIZE, &info[count].colors);
|
||||||
|
aglDescribePixelFormat(pix, AGL_DEPTH_SIZE, &info[count].depth);
|
||||||
|
#ifdef AGL_SAMPLES_ARB
|
||||||
|
aglDescribePixelFormat(pix, AGL_SAMPLES_ARB, &info[count].samples);
|
||||||
|
#else
|
||||||
|
info[count].samples = 0;
|
||||||
|
#endif
|
||||||
|
++count;
|
||||||
|
} while (pix = aglNextPixelFormat(pix));
|
||||||
|
qsort(info, count, sizeof info[0], FBInfoCmp);
|
||||||
|
pix = info[0].pix;
|
||||||
|
free(info);
|
||||||
|
return pix;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
togl_describePixelFormat(Togl *togl)
|
||||||
|
{
|
||||||
|
AGLPixelFormat pixelformat;
|
||||||
|
|
||||||
|
/* fill in RgbaFlag, DoubleFlag, and Stereo */
|
||||||
|
pixelformat = (AGLPixelFormat) togl->PixelFormat;
|
||||||
|
GLint has_rgba, has_doublebuf, has_depth, has_accum, has_alpha,
|
||||||
|
has_stencil, has_stereo, has_multisample;
|
||||||
|
|
||||||
|
if (aglDescribePixelFormat(pixelformat, AGL_RGBA, &has_rgba)
|
||||||
|
&& aglDescribePixelFormat(pixelformat, AGL_DOUBLEBUFFER,
|
||||||
|
&has_doublebuf)
|
||||||
|
&& aglDescribePixelFormat(pixelformat, AGL_DEPTH_SIZE, &has_depth)
|
||||||
|
&& aglDescribePixelFormat(pixelformat, AGL_ACCUM_RED_SIZE,
|
||||||
|
&has_accum)
|
||||||
|
&& aglDescribePixelFormat(pixelformat, AGL_ALPHA_SIZE, &has_alpha)
|
||||||
|
&& aglDescribePixelFormat(pixelformat, AGL_STENCIL_SIZE,
|
||||||
|
&has_stencil)
|
||||||
|
&& aglDescribePixelFormat(pixelformat, AGL_STEREO, &has_stereo)
|
||||||
|
#ifdef AGL_SAMPLES_ARB
|
||||||
|
&& aglDescribePixelFormat(pixelformat, AGL_SAMPLES_ARB,
|
||||||
|
&has_multisample)
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
|
togl->RgbaFlag = (has_rgba != 0);
|
||||||
|
togl->DoubleFlag = (has_doublebuf != 0);
|
||||||
|
togl->DepthFlag = (has_depth != 0);
|
||||||
|
togl->AccumFlag = (has_accum != 0);
|
||||||
|
togl->AlphaFlag = (has_alpha != 0);
|
||||||
|
togl->StencilFlag = (has_stencil != 0);
|
||||||
|
togl->Stereo = (has_stereo ? TOGL_STEREO_NATIVE : TOGL_STEREO_NONE);
|
||||||
|
#ifdef AGL_SAMPLES_ARB
|
||||||
|
togl->MultisampleFlag = (has_multisample != 0);
|
||||||
|
#else
|
||||||
|
togl->MultisampleFlag = False;
|
||||||
|
#endif
|
||||||
|
return True;
|
||||||
|
} else {
|
||||||
|
Tcl_SetResult(togl->Interp,
|
||||||
|
TCL_STUPID "failed querying pixel format attributes",
|
||||||
|
TCL_STATIC);
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define isPow2(x) (((x) & ((x) - 1)) == 0)
|
||||||
|
|
||||||
|
static AGLPbuffer
|
||||||
|
togl_createPbuffer(Togl *togl)
|
||||||
|
{
|
||||||
|
GLint min_size[2], max_size[2];
|
||||||
|
Bool hasPbuffer;
|
||||||
|
const char *extensions;
|
||||||
|
GLboolean good;
|
||||||
|
GLint target;
|
||||||
|
GLint virtualScreen;
|
||||||
|
AGLPbuffer pbuf;
|
||||||
|
|
||||||
|
extensions = (const char *) glGetString(GL_EXTENSIONS);
|
||||||
|
hasPbuffer = (strstr(extensions, "GL_APPLE_pixel_buffer") != NULL);
|
||||||
|
if (!hasPbuffer) {
|
||||||
|
Tcl_SetResult(togl->Interp,
|
||||||
|
TCL_STUPID "pbuffers are not supported", TCL_STATIC);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
glGetIntegerv(GL_MIN_PBUFFER_VIEWPORT_DIMS_APPLE, min_size);
|
||||||
|
glGetIntegerv(GL_MAX_VIEWPORT_DIMS, max_size);
|
||||||
|
virtualScreen = aglGetVirtualScreen(togl->Ctx);
|
||||||
|
for (;;) {
|
||||||
|
/* make sure we don't exceed the maximum size because if we do,
|
||||||
|
* aglCreatePbuffer may succeed and later uses of the pbuffer fail */
|
||||||
|
if (togl->Width < min_size[0])
|
||||||
|
togl->Width = min_size[0];
|
||||||
|
else if (togl->Width > max_size[0]) {
|
||||||
|
if (togl->LargestPbufferFlag)
|
||||||
|
togl->Width = max_size[0];
|
||||||
|
else {
|
||||||
|
Tcl_SetResult(togl->Interp,
|
||||||
|
TCL_STUPID "pbuffer too large", TCL_STATIC);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (togl->Height < min_size[1])
|
||||||
|
togl->Height = min_size[1];
|
||||||
|
else if (togl->Height > max_size[1]) {
|
||||||
|
if (togl->LargestPbufferFlag)
|
||||||
|
togl->Height = max_size[1];
|
||||||
|
else {
|
||||||
|
Tcl_SetResult(togl->Interp,
|
||||||
|
TCL_STUPID "pbuffer too large", TCL_STATIC);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isPow2(togl->Width) && isPow2(togl->Height))
|
||||||
|
target = GL_TEXTURE_2D;
|
||||||
|
else
|
||||||
|
target = GL_TEXTURE_RECTANGLE_ARB;
|
||||||
|
|
||||||
|
good = aglCreatePBuffer(togl->Width, togl->Height, target,
|
||||||
|
togl->AlphaFlag ? GL_RGBA : GL_RGB, 0, &pbuf);
|
||||||
|
if (good) {
|
||||||
|
/* aglSetPbuffer allocates the framebuffer space */
|
||||||
|
if (aglSetPBuffer(togl->Ctx, pbuf, 0, 0, virtualScreen)) {
|
||||||
|
return pbuf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!togl->LargestPbufferFlag
|
||||||
|
|| togl->Width == min_size[0] || togl->Height == min_size[1]) {
|
||||||
|
Tcl_SetResult(togl->Interp,
|
||||||
|
TCL_STUPID "unable to create pbuffer", TCL_STATIC);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/* largest unavailable, try something smaller */
|
||||||
|
togl->Width = togl->Width / 2 + togl->Width % 2;
|
||||||
|
togl->Height = togl->Width / 2 + togl->Height % 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
togl_destroyPbuffer(Togl *togl)
|
||||||
|
{
|
||||||
|
aglDestroyPBuffer(togl->pbuf);
|
||||||
|
}
|
546
ng/Togl2.1/toglDecls.h
Executable file
546
ng/Togl2.1/toglDecls.h
Executable file
@ -0,0 +1,546 @@
|
|||||||
|
#ifndef ToglDecls_H
|
||||||
|
# define ToglDecls_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl - a Tk OpenGL widget
|
||||||
|
*
|
||||||
|
* Copyright (C) 1996-2002 Brian Paul and Ben Bederson
|
||||||
|
* Copyright (C) 2005-2009 Greg Couch
|
||||||
|
* See the LICENSE file for copyright details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* !BEGIN!: Do not edit below this line. */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Exported function declarations:
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef Togl_Init_TCL_DECLARED
|
||||||
|
#define Togl_Init_TCL_DECLARED
|
||||||
|
/* 0 */
|
||||||
|
EXTERN int Togl_Init(Tcl_Interp *interp);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_MakeCurrent_TCL_DECLARED
|
||||||
|
#define Togl_MakeCurrent_TCL_DECLARED
|
||||||
|
/* 1 */
|
||||||
|
EXTERN void Togl_MakeCurrent(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_PostRedisplay_TCL_DECLARED
|
||||||
|
#define Togl_PostRedisplay_TCL_DECLARED
|
||||||
|
/* 2 */
|
||||||
|
EXTERN void Togl_PostRedisplay(Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_SwapBuffers_TCL_DECLARED
|
||||||
|
#define Togl_SwapBuffers_TCL_DECLARED
|
||||||
|
/* 3 */
|
||||||
|
EXTERN void Togl_SwapBuffers(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_Ident_TCL_DECLARED
|
||||||
|
#define Togl_Ident_TCL_DECLARED
|
||||||
|
/* 4 */
|
||||||
|
EXTERN const char * Togl_Ident(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_Width_TCL_DECLARED
|
||||||
|
#define Togl_Width_TCL_DECLARED
|
||||||
|
/* 5 */
|
||||||
|
EXTERN int Togl_Width(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_Height_TCL_DECLARED
|
||||||
|
#define Togl_Height_TCL_DECLARED
|
||||||
|
/* 6 */
|
||||||
|
EXTERN int Togl_Height(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_Interp_TCL_DECLARED
|
||||||
|
#define Togl_Interp_TCL_DECLARED
|
||||||
|
/* 7 */
|
||||||
|
EXTERN Tcl_Interp * Togl_Interp(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_TkWin_TCL_DECLARED
|
||||||
|
#define Togl_TkWin_TCL_DECLARED
|
||||||
|
/* 8 */
|
||||||
|
EXTERN Tk_Window Togl_TkWin(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_CommandName_TCL_DECLARED
|
||||||
|
#define Togl_CommandName_TCL_DECLARED
|
||||||
|
/* 9 */
|
||||||
|
EXTERN const char * Togl_CommandName(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_AllocColor_TCL_DECLARED
|
||||||
|
#define Togl_AllocColor_TCL_DECLARED
|
||||||
|
/* 10 */
|
||||||
|
EXTERN unsigned long Togl_AllocColor(const Togl *togl, float red,
|
||||||
|
float green, float blue);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_FreeColor_TCL_DECLARED
|
||||||
|
#define Togl_FreeColor_TCL_DECLARED
|
||||||
|
/* 11 */
|
||||||
|
EXTERN void Togl_FreeColor(const Togl *togl, unsigned long index);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_SetColor_TCL_DECLARED
|
||||||
|
#define Togl_SetColor_TCL_DECLARED
|
||||||
|
/* 12 */
|
||||||
|
EXTERN void Togl_SetColor(const Togl *togl, unsigned long index,
|
||||||
|
float red, float green, float blue);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_LoadBitmapFont_TCL_DECLARED
|
||||||
|
#define Togl_LoadBitmapFont_TCL_DECLARED
|
||||||
|
/* 13 */
|
||||||
|
EXTERN Tcl_Obj * Togl_LoadBitmapFont(const Togl *togl,
|
||||||
|
const char *fontname);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_UnloadBitmapFont_TCL_DECLARED
|
||||||
|
#define Togl_UnloadBitmapFont_TCL_DECLARED
|
||||||
|
/* 14 */
|
||||||
|
EXTERN int Togl_UnloadBitmapFont(const Togl *togl,
|
||||||
|
Tcl_Obj *toglfont);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_UseLayer_TCL_DECLARED
|
||||||
|
#define Togl_UseLayer_TCL_DECLARED
|
||||||
|
/* 15 */
|
||||||
|
EXTERN void Togl_UseLayer(Togl *togl, int layer);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_ShowOverlay_TCL_DECLARED
|
||||||
|
#define Togl_ShowOverlay_TCL_DECLARED
|
||||||
|
/* 16 */
|
||||||
|
EXTERN void Togl_ShowOverlay(Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_HideOverlay_TCL_DECLARED
|
||||||
|
#define Togl_HideOverlay_TCL_DECLARED
|
||||||
|
/* 17 */
|
||||||
|
EXTERN void Togl_HideOverlay(Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_PostOverlayRedisplay_TCL_DECLARED
|
||||||
|
#define Togl_PostOverlayRedisplay_TCL_DECLARED
|
||||||
|
/* 18 */
|
||||||
|
EXTERN void Togl_PostOverlayRedisplay(Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_ExistsOverlay_TCL_DECLARED
|
||||||
|
#define Togl_ExistsOverlay_TCL_DECLARED
|
||||||
|
/* 19 */
|
||||||
|
EXTERN int Togl_ExistsOverlay(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_GetOverlayTransparentValue_TCL_DECLARED
|
||||||
|
#define Togl_GetOverlayTransparentValue_TCL_DECLARED
|
||||||
|
/* 20 */
|
||||||
|
EXTERN int Togl_GetOverlayTransparentValue(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_IsMappedOverlay_TCL_DECLARED
|
||||||
|
#define Togl_IsMappedOverlay_TCL_DECLARED
|
||||||
|
/* 21 */
|
||||||
|
EXTERN int Togl_IsMappedOverlay(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_AllocColorOverlay_TCL_DECLARED
|
||||||
|
#define Togl_AllocColorOverlay_TCL_DECLARED
|
||||||
|
/* 22 */
|
||||||
|
EXTERN unsigned long Togl_AllocColorOverlay(const Togl *togl, float red,
|
||||||
|
float green, float blue);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_FreeColorOverlay_TCL_DECLARED
|
||||||
|
#define Togl_FreeColorOverlay_TCL_DECLARED
|
||||||
|
/* 23 */
|
||||||
|
EXTERN void Togl_FreeColorOverlay(const Togl *togl,
|
||||||
|
unsigned long index);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_GetClientData_TCL_DECLARED
|
||||||
|
#define Togl_GetClientData_TCL_DECLARED
|
||||||
|
/* 24 */
|
||||||
|
EXTERN ClientData Togl_GetClientData(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_SetClientData_TCL_DECLARED
|
||||||
|
#define Togl_SetClientData_TCL_DECLARED
|
||||||
|
/* 25 */
|
||||||
|
EXTERN void Togl_SetClientData(Togl *togl, ClientData clientData);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_DrawBuffer_TCL_DECLARED
|
||||||
|
#define Togl_DrawBuffer_TCL_DECLARED
|
||||||
|
/* 26 */
|
||||||
|
EXTERN void Togl_DrawBuffer(Togl *togl, GLenum mode);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_Clear_TCL_DECLARED
|
||||||
|
#define Togl_Clear_TCL_DECLARED
|
||||||
|
/* 27 */
|
||||||
|
EXTERN void Togl_Clear(const Togl *togl, GLbitfield mask);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_Frustum_TCL_DECLARED
|
||||||
|
#define Togl_Frustum_TCL_DECLARED
|
||||||
|
/* 28 */
|
||||||
|
EXTERN void Togl_Frustum(const Togl *togl, GLdouble left,
|
||||||
|
GLdouble right, GLdouble bottom,
|
||||||
|
GLdouble top, GLdouble near, GLdouble far);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_GetToglFromObj_TCL_DECLARED
|
||||||
|
#define Togl_GetToglFromObj_TCL_DECLARED
|
||||||
|
/* 29 */
|
||||||
|
EXTERN int Togl_GetToglFromObj(Tcl_Interp *interp, Tcl_Obj *obj,
|
||||||
|
Togl **toglPtr);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_TakePhoto_TCL_DECLARED
|
||||||
|
#define Togl_TakePhoto_TCL_DECLARED
|
||||||
|
/* 30 */
|
||||||
|
EXTERN int Togl_TakePhoto(Togl *togl, Tk_PhotoHandle photo);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_GetProcAddr_TCL_DECLARED
|
||||||
|
#define Togl_GetProcAddr_TCL_DECLARED
|
||||||
|
/* 31 */
|
||||||
|
EXTERN Togl_FuncPtr Togl_GetProcAddr(const char *funcname);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_GetToglFromName_TCL_DECLARED
|
||||||
|
#define Togl_GetToglFromName_TCL_DECLARED
|
||||||
|
/* 32 */
|
||||||
|
EXTERN int Togl_GetToglFromName(Tcl_Interp *interp,
|
||||||
|
const char *cmdName, Togl **toglPtr);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_SwapInterval_TCL_DECLARED
|
||||||
|
#define Togl_SwapInterval_TCL_DECLARED
|
||||||
|
/* 33 */
|
||||||
|
EXTERN Bool Togl_SwapInterval(const Togl *togl, int interval);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_Ortho_TCL_DECLARED
|
||||||
|
#define Togl_Ortho_TCL_DECLARED
|
||||||
|
/* 34 */
|
||||||
|
EXTERN void Togl_Ortho(const Togl *togl, GLdouble left,
|
||||||
|
GLdouble right, GLdouble bottom,
|
||||||
|
GLdouble top, GLdouble near, GLdouble far);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_NumEyes_TCL_DECLARED
|
||||||
|
#define Togl_NumEyes_TCL_DECLARED
|
||||||
|
/* 35 */
|
||||||
|
EXTERN int Togl_NumEyes(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_ContextTag_TCL_DECLARED
|
||||||
|
#define Togl_ContextTag_TCL_DECLARED
|
||||||
|
/* 36 */
|
||||||
|
EXTERN int Togl_ContextTag(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_UpdatePending_TCL_DECLARED
|
||||||
|
#define Togl_UpdatePending_TCL_DECLARED
|
||||||
|
/* 37 */
|
||||||
|
EXTERN Bool Togl_UpdatePending(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_WriteObj_TCL_DECLARED
|
||||||
|
#define Togl_WriteObj_TCL_DECLARED
|
||||||
|
/* 38 */
|
||||||
|
EXTERN int Togl_WriteObj(const Togl *togl,
|
||||||
|
const Tcl_Obj *toglfont, Tcl_Obj *obj);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_WriteChars_TCL_DECLARED
|
||||||
|
#define Togl_WriteChars_TCL_DECLARED
|
||||||
|
/* 39 */
|
||||||
|
EXTERN int Togl_WriteChars(const Togl *togl,
|
||||||
|
const Tcl_Obj *toglfont, const char *str,
|
||||||
|
int len);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_HasRGBA_TCL_DECLARED
|
||||||
|
#define Togl_HasRGBA_TCL_DECLARED
|
||||||
|
/* 40 */
|
||||||
|
EXTERN Bool Togl_HasRGBA(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_IsDoubleBuffered_TCL_DECLARED
|
||||||
|
#define Togl_IsDoubleBuffered_TCL_DECLARED
|
||||||
|
/* 41 */
|
||||||
|
EXTERN Bool Togl_IsDoubleBuffered(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_HasDepthBuffer_TCL_DECLARED
|
||||||
|
#define Togl_HasDepthBuffer_TCL_DECLARED
|
||||||
|
/* 42 */
|
||||||
|
EXTERN Bool Togl_HasDepthBuffer(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_HasAccumulationBuffer_TCL_DECLARED
|
||||||
|
#define Togl_HasAccumulationBuffer_TCL_DECLARED
|
||||||
|
/* 43 */
|
||||||
|
EXTERN Bool Togl_HasAccumulationBuffer(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_HasDestinationAlpha_TCL_DECLARED
|
||||||
|
#define Togl_HasDestinationAlpha_TCL_DECLARED
|
||||||
|
/* 44 */
|
||||||
|
EXTERN Bool Togl_HasDestinationAlpha(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_HasStencilBuffer_TCL_DECLARED
|
||||||
|
#define Togl_HasStencilBuffer_TCL_DECLARED
|
||||||
|
/* 45 */
|
||||||
|
EXTERN Bool Togl_HasStencilBuffer(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_StereoMode_TCL_DECLARED
|
||||||
|
#define Togl_StereoMode_TCL_DECLARED
|
||||||
|
/* 46 */
|
||||||
|
EXTERN int Togl_StereoMode(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_HasMultisample_TCL_DECLARED
|
||||||
|
#define Togl_HasMultisample_TCL_DECLARED
|
||||||
|
/* 47 */
|
||||||
|
EXTERN Bool Togl_HasMultisample(const Togl *togl);
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_CopyContext_TCL_DECLARED
|
||||||
|
#define Togl_CopyContext_TCL_DECLARED
|
||||||
|
/* 48 */
|
||||||
|
EXTERN int Togl_CopyContext(const Togl *from, const Togl *to,
|
||||||
|
unsigned int mask);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct ToglStubs {
|
||||||
|
int magic;
|
||||||
|
const struct ToglStubHooks *hooks;
|
||||||
|
|
||||||
|
int (*togl_Init) (Tcl_Interp *interp); /* 0 */
|
||||||
|
void (*togl_MakeCurrent) (const Togl *togl); /* 1 */
|
||||||
|
void (*togl_PostRedisplay) (Togl *togl); /* 2 */
|
||||||
|
void (*togl_SwapBuffers) (const Togl *togl); /* 3 */
|
||||||
|
const char * (*togl_Ident) (const Togl *togl); /* 4 */
|
||||||
|
int (*togl_Width) (const Togl *togl); /* 5 */
|
||||||
|
int (*togl_Height) (const Togl *togl); /* 6 */
|
||||||
|
Tcl_Interp * (*togl_Interp) (const Togl *togl); /* 7 */
|
||||||
|
Tk_Window (*togl_TkWin) (const Togl *togl); /* 8 */
|
||||||
|
const char * (*togl_CommandName) (const Togl *togl); /* 9 */
|
||||||
|
unsigned long (*togl_AllocColor) (const Togl *togl, float red, float green, float blue); /* 10 */
|
||||||
|
void (*togl_FreeColor) (const Togl *togl, unsigned long index); /* 11 */
|
||||||
|
void (*togl_SetColor) (const Togl *togl, unsigned long index, float red, float green, float blue); /* 12 */
|
||||||
|
Tcl_Obj * (*togl_LoadBitmapFont) (const Togl *togl, const char *fontname); /* 13 */
|
||||||
|
int (*togl_UnloadBitmapFont) (const Togl *togl, Tcl_Obj *toglfont); /* 14 */
|
||||||
|
void (*togl_UseLayer) (Togl *togl, int layer); /* 15 */
|
||||||
|
void (*togl_ShowOverlay) (Togl *togl); /* 16 */
|
||||||
|
void (*togl_HideOverlay) (Togl *togl); /* 17 */
|
||||||
|
void (*togl_PostOverlayRedisplay) (Togl *togl); /* 18 */
|
||||||
|
int (*togl_ExistsOverlay) (const Togl *togl); /* 19 */
|
||||||
|
int (*togl_GetOverlayTransparentValue) (const Togl *togl); /* 20 */
|
||||||
|
int (*togl_IsMappedOverlay) (const Togl *togl); /* 21 */
|
||||||
|
unsigned long (*togl_AllocColorOverlay) (const Togl *togl, float red, float green, float blue); /* 22 */
|
||||||
|
void (*togl_FreeColorOverlay) (const Togl *togl, unsigned long index); /* 23 */
|
||||||
|
ClientData (*togl_GetClientData) (const Togl *togl); /* 24 */
|
||||||
|
void (*togl_SetClientData) (Togl *togl, ClientData clientData); /* 25 */
|
||||||
|
void (*togl_DrawBuffer) (Togl *togl, GLenum mode); /* 26 */
|
||||||
|
void (*togl_Clear) (const Togl *togl, GLbitfield mask); /* 27 */
|
||||||
|
void (*togl_Frustum) (const Togl *togl, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far); /* 28 */
|
||||||
|
int (*togl_GetToglFromObj) (Tcl_Interp *interp, Tcl_Obj *obj, Togl **toglPtr); /* 29 */
|
||||||
|
int (*togl_TakePhoto) (Togl *togl, Tk_PhotoHandle photo); /* 30 */
|
||||||
|
Togl_FuncPtr (*togl_GetProcAddr) (const char *funcname); /* 31 */
|
||||||
|
int (*togl_GetToglFromName) (Tcl_Interp *interp, const char *cmdName, Togl **toglPtr); /* 32 */
|
||||||
|
Bool (*togl_SwapInterval) (const Togl *togl, int interval); /* 33 */
|
||||||
|
void (*togl_Ortho) (const Togl *togl, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far); /* 34 */
|
||||||
|
int (*togl_NumEyes) (const Togl *togl); /* 35 */
|
||||||
|
int (*togl_ContextTag) (const Togl *togl); /* 36 */
|
||||||
|
Bool (*togl_UpdatePending) (const Togl *togl); /* 37 */
|
||||||
|
int (*togl_WriteObj) (const Togl *togl, const Tcl_Obj *toglfont, Tcl_Obj *obj); /* 38 */
|
||||||
|
int (*togl_WriteChars) (const Togl *togl, const Tcl_Obj *toglfont, const char *str, int len); /* 39 */
|
||||||
|
Bool (*togl_HasRGBA) (const Togl *togl); /* 40 */
|
||||||
|
Bool (*togl_IsDoubleBuffered) (const Togl *togl); /* 41 */
|
||||||
|
Bool (*togl_HasDepthBuffer) (const Togl *togl); /* 42 */
|
||||||
|
Bool (*togl_HasAccumulationBuffer) (const Togl *togl); /* 43 */
|
||||||
|
Bool (*togl_HasDestinationAlpha) (const Togl *togl); /* 44 */
|
||||||
|
Bool (*togl_HasStencilBuffer) (const Togl *togl); /* 45 */
|
||||||
|
int (*togl_StereoMode) (const Togl *togl); /* 46 */
|
||||||
|
Bool (*togl_HasMultisample) (const Togl *togl); /* 47 */
|
||||||
|
int (*togl_CopyContext) (const Togl *from, const Togl *to, unsigned int mask); /* 48 */
|
||||||
|
} ToglStubs;
|
||||||
|
|
||||||
|
#if defined(USE_TOGL_STUBS) && !defined(USE_TOGL_STUB_PROCS)
|
||||||
|
extern const ToglStubs *toglStubsPtr;
|
||||||
|
#endif /* defined(USE_TOGL_STUBS) && !defined(USE_TOGL_STUB_PROCS) */
|
||||||
|
|
||||||
|
#if defined(USE_TOGL_STUBS) && !defined(USE_TOGL_STUB_PROCS)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Inline function declarations:
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef Togl_Init
|
||||||
|
#define Togl_Init \
|
||||||
|
(toglStubsPtr->togl_Init) /* 0 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_MakeCurrent
|
||||||
|
#define Togl_MakeCurrent \
|
||||||
|
(toglStubsPtr->togl_MakeCurrent) /* 1 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_PostRedisplay
|
||||||
|
#define Togl_PostRedisplay \
|
||||||
|
(toglStubsPtr->togl_PostRedisplay) /* 2 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_SwapBuffers
|
||||||
|
#define Togl_SwapBuffers \
|
||||||
|
(toglStubsPtr->togl_SwapBuffers) /* 3 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_Ident
|
||||||
|
#define Togl_Ident \
|
||||||
|
(toglStubsPtr->togl_Ident) /* 4 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_Width
|
||||||
|
#define Togl_Width \
|
||||||
|
(toglStubsPtr->togl_Width) /* 5 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_Height
|
||||||
|
#define Togl_Height \
|
||||||
|
(toglStubsPtr->togl_Height) /* 6 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_Interp
|
||||||
|
#define Togl_Interp \
|
||||||
|
(toglStubsPtr->togl_Interp) /* 7 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_TkWin
|
||||||
|
#define Togl_TkWin \
|
||||||
|
(toglStubsPtr->togl_TkWin) /* 8 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_CommandName
|
||||||
|
#define Togl_CommandName \
|
||||||
|
(toglStubsPtr->togl_CommandName) /* 9 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_AllocColor
|
||||||
|
#define Togl_AllocColor \
|
||||||
|
(toglStubsPtr->togl_AllocColor) /* 10 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_FreeColor
|
||||||
|
#define Togl_FreeColor \
|
||||||
|
(toglStubsPtr->togl_FreeColor) /* 11 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_SetColor
|
||||||
|
#define Togl_SetColor \
|
||||||
|
(toglStubsPtr->togl_SetColor) /* 12 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_LoadBitmapFont
|
||||||
|
#define Togl_LoadBitmapFont \
|
||||||
|
(toglStubsPtr->togl_LoadBitmapFont) /* 13 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_UnloadBitmapFont
|
||||||
|
#define Togl_UnloadBitmapFont \
|
||||||
|
(toglStubsPtr->togl_UnloadBitmapFont) /* 14 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_UseLayer
|
||||||
|
#define Togl_UseLayer \
|
||||||
|
(toglStubsPtr->togl_UseLayer) /* 15 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_ShowOverlay
|
||||||
|
#define Togl_ShowOverlay \
|
||||||
|
(toglStubsPtr->togl_ShowOverlay) /* 16 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_HideOverlay
|
||||||
|
#define Togl_HideOverlay \
|
||||||
|
(toglStubsPtr->togl_HideOverlay) /* 17 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_PostOverlayRedisplay
|
||||||
|
#define Togl_PostOverlayRedisplay \
|
||||||
|
(toglStubsPtr->togl_PostOverlayRedisplay) /* 18 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_ExistsOverlay
|
||||||
|
#define Togl_ExistsOverlay \
|
||||||
|
(toglStubsPtr->togl_ExistsOverlay) /* 19 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_GetOverlayTransparentValue
|
||||||
|
#define Togl_GetOverlayTransparentValue \
|
||||||
|
(toglStubsPtr->togl_GetOverlayTransparentValue) /* 20 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_IsMappedOverlay
|
||||||
|
#define Togl_IsMappedOverlay \
|
||||||
|
(toglStubsPtr->togl_IsMappedOverlay) /* 21 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_AllocColorOverlay
|
||||||
|
#define Togl_AllocColorOverlay \
|
||||||
|
(toglStubsPtr->togl_AllocColorOverlay) /* 22 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_FreeColorOverlay
|
||||||
|
#define Togl_FreeColorOverlay \
|
||||||
|
(toglStubsPtr->togl_FreeColorOverlay) /* 23 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_GetClientData
|
||||||
|
#define Togl_GetClientData \
|
||||||
|
(toglStubsPtr->togl_GetClientData) /* 24 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_SetClientData
|
||||||
|
#define Togl_SetClientData \
|
||||||
|
(toglStubsPtr->togl_SetClientData) /* 25 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_DrawBuffer
|
||||||
|
#define Togl_DrawBuffer \
|
||||||
|
(toglStubsPtr->togl_DrawBuffer) /* 26 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_Clear
|
||||||
|
#define Togl_Clear \
|
||||||
|
(toglStubsPtr->togl_Clear) /* 27 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_Frustum
|
||||||
|
#define Togl_Frustum \
|
||||||
|
(toglStubsPtr->togl_Frustum) /* 28 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_GetToglFromObj
|
||||||
|
#define Togl_GetToglFromObj \
|
||||||
|
(toglStubsPtr->togl_GetToglFromObj) /* 29 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_TakePhoto
|
||||||
|
#define Togl_TakePhoto \
|
||||||
|
(toglStubsPtr->togl_TakePhoto) /* 30 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_GetProcAddr
|
||||||
|
#define Togl_GetProcAddr \
|
||||||
|
(toglStubsPtr->togl_GetProcAddr) /* 31 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_GetToglFromName
|
||||||
|
#define Togl_GetToglFromName \
|
||||||
|
(toglStubsPtr->togl_GetToglFromName) /* 32 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_SwapInterval
|
||||||
|
#define Togl_SwapInterval \
|
||||||
|
(toglStubsPtr->togl_SwapInterval) /* 33 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_Ortho
|
||||||
|
#define Togl_Ortho \
|
||||||
|
(toglStubsPtr->togl_Ortho) /* 34 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_NumEyes
|
||||||
|
#define Togl_NumEyes \
|
||||||
|
(toglStubsPtr->togl_NumEyes) /* 35 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_ContextTag
|
||||||
|
#define Togl_ContextTag \
|
||||||
|
(toglStubsPtr->togl_ContextTag) /* 36 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_UpdatePending
|
||||||
|
#define Togl_UpdatePending \
|
||||||
|
(toglStubsPtr->togl_UpdatePending) /* 37 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_WriteObj
|
||||||
|
#define Togl_WriteObj \
|
||||||
|
(toglStubsPtr->togl_WriteObj) /* 38 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_WriteChars
|
||||||
|
#define Togl_WriteChars \
|
||||||
|
(toglStubsPtr->togl_WriteChars) /* 39 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_HasRGBA
|
||||||
|
#define Togl_HasRGBA \
|
||||||
|
(toglStubsPtr->togl_HasRGBA) /* 40 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_IsDoubleBuffered
|
||||||
|
#define Togl_IsDoubleBuffered \
|
||||||
|
(toglStubsPtr->togl_IsDoubleBuffered) /* 41 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_HasDepthBuffer
|
||||||
|
#define Togl_HasDepthBuffer \
|
||||||
|
(toglStubsPtr->togl_HasDepthBuffer) /* 42 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_HasAccumulationBuffer
|
||||||
|
#define Togl_HasAccumulationBuffer \
|
||||||
|
(toglStubsPtr->togl_HasAccumulationBuffer) /* 43 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_HasDestinationAlpha
|
||||||
|
#define Togl_HasDestinationAlpha \
|
||||||
|
(toglStubsPtr->togl_HasDestinationAlpha) /* 44 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_HasStencilBuffer
|
||||||
|
#define Togl_HasStencilBuffer \
|
||||||
|
(toglStubsPtr->togl_HasStencilBuffer) /* 45 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_StereoMode
|
||||||
|
#define Togl_StereoMode \
|
||||||
|
(toglStubsPtr->togl_StereoMode) /* 46 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_HasMultisample
|
||||||
|
#define Togl_HasMultisample \
|
||||||
|
(toglStubsPtr->togl_HasMultisample) /* 47 */
|
||||||
|
#endif
|
||||||
|
#ifndef Togl_CopyContext
|
||||||
|
#define Togl_CopyContext \
|
||||||
|
(toglStubsPtr->togl_CopyContext) /* 48 */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* defined(USE_TOGL_STUBS) && !defined(USE_TOGL_STUB_PROCS) */
|
||||||
|
|
||||||
|
/* !END!: Do not edit above this line. */
|
||||||
|
|
||||||
|
#endif
|
447
ng/Togl2.1/toglFont.c
Normal file
447
ng/Togl2.1/toglFont.c
Normal file
@ -0,0 +1,447 @@
|
|||||||
|
/* $Id: toglFont.c,v 1.8 2009/05/22 00:18:36 gregcouch Exp $ */
|
||||||
|
|
||||||
|
/* vi:set sw=4 expandtab: */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl - a Tk OpenGL widget
|
||||||
|
*
|
||||||
|
* Copyright (C) 1996-2002 Brian Paul and Ben Bederson
|
||||||
|
* Copyright (C) 2005-2008 Greg Couch
|
||||||
|
* See the LICENSE file for copyright details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl Bitmap Font support
|
||||||
|
*
|
||||||
|
* If bitmap font support is requested, then this file is included into
|
||||||
|
* togl.c. Parts of this file are based on <http://wiki.tcl.tk/13881>,
|
||||||
|
* "Creating and Using Tcl Handles in C Extensions".
|
||||||
|
*
|
||||||
|
* Neither the Tk public nor the internal interface give enough information
|
||||||
|
* to reuse the font in OpenGL, so we copy the private structures here to
|
||||||
|
* access what we need.
|
||||||
|
*
|
||||||
|
* Globals needed by the font module are in togl.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <tkFont.h>
|
||||||
|
|
||||||
|
struct Togl_BitmapFontInfo
|
||||||
|
{
|
||||||
|
GLuint base;
|
||||||
|
GLuint first;
|
||||||
|
GLuint last;
|
||||||
|
int contextTag;
|
||||||
|
/* TODO: keep original font and/or encoding */
|
||||||
|
};
|
||||||
|
typedef struct Togl_BitmapFontInfo Togl_BitmapFontInfo;
|
||||||
|
|
||||||
|
#define BITMAP_FONT_INFO(obj) \
|
||||||
|
((Togl_BitmapFontInfo *) (obj)->internalRep.otherValuePtr)
|
||||||
|
#define SET_BITMAP_FONT_INFO(obj) \
|
||||||
|
(obj)->internalRep.otherValuePtr
|
||||||
|
|
||||||
|
static void Togl_FontFree(Tcl_Obj *obj);
|
||||||
|
static void Togl_FontDup(Tcl_Obj *src, Tcl_Obj *dup);
|
||||||
|
static void Togl_FontString(Tcl_Obj *obj);
|
||||||
|
static int Togl_FontSet(Tcl_Interp *interp, Tcl_Obj *obj);
|
||||||
|
|
||||||
|
static Tcl_ObjType Togl_BitmapFontType = {
|
||||||
|
"Togl BitmapFont", /* name */
|
||||||
|
Togl_FontFree, /* free internal rep */
|
||||||
|
Togl_FontDup, /* dup internal rep */
|
||||||
|
Togl_FontString, /* update string from internal rep */
|
||||||
|
Togl_FontSet /* set internal rep from string */
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
Togl_FontSet(Tcl_Interp *interp, Tcl_Obj *obj)
|
||||||
|
{
|
||||||
|
if (interp)
|
||||||
|
Tcl_AppendResult(interp, "cannot (re)build object of type \"",
|
||||||
|
Togl_BitmapFontType.name, "\"", NULL);
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
Togl_FontFree(Tcl_Obj *obj)
|
||||||
|
{
|
||||||
|
Togl_BitmapFontInfo *bfi = BITMAP_FONT_INFO(obj);
|
||||||
|
|
||||||
|
ckfree((char *) bfi);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
Togl_FontString(Tcl_Obj *obj)
|
||||||
|
{
|
||||||
|
/* assert(obj->bytes == NULL) */
|
||||||
|
static char buf[256];
|
||||||
|
register unsigned len;
|
||||||
|
Togl_BitmapFontInfo *bfi = BITMAP_FONT_INFO(obj);
|
||||||
|
|
||||||
|
#if !defined(TOGL_AGL) && !defined(TOGL_NSOPENGL)
|
||||||
|
snprintf(buf, sizeof buf - 1, "{{%s} %d %d %d}",
|
||||||
|
Togl_BitmapFontType.name, bfi->base, bfi->first, bfi->last);
|
||||||
|
#else
|
||||||
|
/* unlike every other platform, on Aqua, GLint is long */
|
||||||
|
snprintf(buf, sizeof buf - 1, "{{%s} %ld %ld %ld}",
|
||||||
|
Togl_BitmapFontType.name, bfi->base, bfi->first, bfi->last);
|
||||||
|
#endif
|
||||||
|
buf[sizeof buf - 1] = '\0';
|
||||||
|
len = strlen(buf);
|
||||||
|
obj->bytes = (char *) ckalloc(len + 1);
|
||||||
|
strcpy(obj->bytes, buf);
|
||||||
|
obj->length = len;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
Togl_FontDup(Tcl_Obj *src, Tcl_Obj *dup)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* When duplicated, lose the font-ness and just be a string.
|
||||||
|
* So don't copy the internal representation and don't set
|
||||||
|
* dup->typePtr.
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(TOGL_X11)
|
||||||
|
/* From tkUnixFont.c */
|
||||||
|
/*
|
||||||
|
* The following structure encapsulates an individual screen font. A font
|
||||||
|
* object is made up of however many SubFonts are necessary to display a
|
||||||
|
* stream of multilingual characters.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct FontFamily FontFamily;
|
||||||
|
|
||||||
|
typedef struct SubFont
|
||||||
|
{
|
||||||
|
char **fontMap; /* Pointer to font map from the FontFamily,
|
||||||
|
* cached here to save a dereference. */
|
||||||
|
XFontStruct *fontStructPtr; /* The specific screen font that will be used
|
||||||
|
* when displaying/measuring chars belonging to
|
||||||
|
* the FontFamily. */
|
||||||
|
FontFamily *familyPtr; /* The FontFamily for this SubFont. */
|
||||||
|
} SubFont;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following structure represents Unix's implementation of a font
|
||||||
|
* object.
|
||||||
|
*/
|
||||||
|
|
||||||
|
# define SUBFONT_SPACE 3
|
||||||
|
# define BASE_CHARS 256
|
||||||
|
|
||||||
|
typedef struct UnixFont
|
||||||
|
{
|
||||||
|
TkFont font; /* Stuff used by generic font package. Must be
|
||||||
|
* first in structure. */
|
||||||
|
SubFont staticSubFonts[SUBFONT_SPACE];
|
||||||
|
/* Builtin space for a limited number of SubFonts. */
|
||||||
|
int numSubFonts; /* Length of following array. */
|
||||||
|
SubFont *subFontArray; /* Array of SubFonts that have been loaded in
|
||||||
|
* order to draw/measure all the characters
|
||||||
|
* encountered by this font so far. All fonts
|
||||||
|
* start off with one SubFont initialized by
|
||||||
|
* AllocFont() from the original set of font
|
||||||
|
* attributes. Usually points to
|
||||||
|
* staticSubFonts, but may point to malloced
|
||||||
|
* space if there are lots of SubFonts. */
|
||||||
|
SubFont controlSubFont; /* Font to use to display control-character
|
||||||
|
* expansions. */
|
||||||
|
|
||||||
|
# if 0
|
||||||
|
Display *display; /* Display that owns font. */
|
||||||
|
int pixelSize; /* Original pixel size used when font was
|
||||||
|
* constructed. */
|
||||||
|
TkXLFDAttributes xa; /* Additional attributes that specify the
|
||||||
|
* preferred foundry and encoding to use when
|
||||||
|
* constructing additional SubFonts. */
|
||||||
|
int widths[BASE_CHARS]; /* Widths of first 256 chars in the base font,
|
||||||
|
* for handling common case. */
|
||||||
|
int underlinePos; /* Offset from baseline to origin of underline
|
||||||
|
* bar (used when drawing underlined font)
|
||||||
|
* (pixels). */
|
||||||
|
int barHeight; /* Height of underline or overstrike bar (used
|
||||||
|
* when drawing underlined or strikeout font)
|
||||||
|
* (pixels). */
|
||||||
|
# endif
|
||||||
|
} UnixFont;
|
||||||
|
|
||||||
|
#elif defined(TOGL_WGL)
|
||||||
|
# include <tkWinInt.h>
|
||||||
|
/* From tkWinFont.c */
|
||||||
|
|
||||||
|
typedef struct FontFamily FontFamily;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following structure encapsulates an individual screen font. A font
|
||||||
|
* object is made up of however many SubFonts are necessary to display a
|
||||||
|
* stream of multilingual characters.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct SubFont
|
||||||
|
{
|
||||||
|
char **fontMap; /* Pointer to font map from the FontFamily,
|
||||||
|
* cached here to save a dereference. */
|
||||||
|
HFONT hFont; /* The specific screen font that will be used
|
||||||
|
* when displaying/measuring chars belonging to
|
||||||
|
* the FontFamily. */
|
||||||
|
FontFamily *familyPtr; /* The FontFamily for this SubFont. */
|
||||||
|
} SubFont;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following structure represents Windows' implementation of a font
|
||||||
|
* object.
|
||||||
|
*/
|
||||||
|
|
||||||
|
# define SUBFONT_SPACE 3
|
||||||
|
# define BASE_CHARS 128
|
||||||
|
|
||||||
|
typedef struct WinFont
|
||||||
|
{
|
||||||
|
TkFont font; /* Stuff used by generic font package. Must be
|
||||||
|
* first in structure. */
|
||||||
|
SubFont staticSubFonts[SUBFONT_SPACE];
|
||||||
|
/* Builtin space for a limited number of SubFonts. */
|
||||||
|
int numSubFonts; /* Length of following array. */
|
||||||
|
SubFont *subFontArray; /* Array of SubFonts that have been loaded in
|
||||||
|
* order to draw/measure all the characters
|
||||||
|
* encountered by this font so far. All fonts
|
||||||
|
* start off with one SubFont initialized by
|
||||||
|
* AllocFont() from the original set of font
|
||||||
|
* attributes. Usually points to
|
||||||
|
* staticSubFonts, but may point to malloced
|
||||||
|
* space if there are lots of SubFonts. */
|
||||||
|
|
||||||
|
HWND hwnd; /* Toplevel window of application that owns
|
||||||
|
* this font, used for getting HDC for
|
||||||
|
* offscreen measurements. */
|
||||||
|
int pixelSize; /* Original pixel size used when font was
|
||||||
|
* constructed. */
|
||||||
|
int widths[BASE_CHARS]; /* Widths of first 128 chars in the base font,
|
||||||
|
* for handling common case. The base font is
|
||||||
|
* always used to draw characters between
|
||||||
|
* 0x0000 and 0x007f. */
|
||||||
|
} WinFont;
|
||||||
|
|
||||||
|
#elif defined(TOGL_AGL)
|
||||||
|
|
||||||
|
typedef struct FontFamily
|
||||||
|
{
|
||||||
|
struct FontFamily *nextPtr; /* Next in list of all known font families. */
|
||||||
|
int refCount; /* How many SubFonts are referring to this
|
||||||
|
* FontFamily. When the refCount drops to
|
||||||
|
* zero, this FontFamily may be freed. */
|
||||||
|
/*
|
||||||
|
* Key.
|
||||||
|
*/
|
||||||
|
|
||||||
|
FMFontFamily faceNum; /* Unique face number key for this FontFamily. */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Derived properties.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Tcl_Encoding encoding; /* Encoding for this font family. */
|
||||||
|
# if 0
|
||||||
|
int isSymbolFont; /* Non-zero if this is a symbol family. */
|
||||||
|
int isMultiByteFont; /* Non-zero if this is a multi-byte family. */
|
||||||
|
char typeTable[256]; /* Table that identfies all lead bytes for a
|
||||||
|
* multi-byte family, used when measuring
|
||||||
|
* chars. If a byte is a lead byte, the value
|
||||||
|
* at the corresponding position in the
|
||||||
|
* typeTable is 1, otherwise 0. If this is a
|
||||||
|
* single-byte font, all entries are 0. */
|
||||||
|
char *fontMap[FONTMAP_PAGES];
|
||||||
|
/* Two-level sparse table used to determine quickly if the specified
|
||||||
|
* character exists. As characters are encountered, more pages in this
|
||||||
|
* table are dynamically added. The contents of each page is a bitmask
|
||||||
|
* consisting of FONTMAP_BITSPERPAGE bits, representing whether this font
|
||||||
|
* can be used to display the given character at the corresponding bit
|
||||||
|
* position. The high bits of the character are used to pick which page of
|
||||||
|
* the table is used. */
|
||||||
|
# endif
|
||||||
|
} FontFamily;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following structure encapsulates an individual screen font. A font
|
||||||
|
* object is made up of however many SubFonts are necessary to display a
|
||||||
|
* stream of multilingual characters.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct SubFont
|
||||||
|
{
|
||||||
|
char **fontMap; /* Pointer to font map from the FontFamily,
|
||||||
|
* cached here to save a dereference. */
|
||||||
|
FontFamily *familyPtr; /* The FontFamily for this SubFont. */
|
||||||
|
} SubFont;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following structure represents Macintosh's implementation of a font
|
||||||
|
* object.
|
||||||
|
*/
|
||||||
|
|
||||||
|
# define SUBFONT_SPACE 3
|
||||||
|
|
||||||
|
typedef struct MacFont
|
||||||
|
{
|
||||||
|
TkFont font; /* Stuff used by generic font package. Must be
|
||||||
|
* first in structure. */
|
||||||
|
SubFont staticSubFonts[SUBFONT_SPACE];
|
||||||
|
/* Builtin space for a limited number of SubFonts. */
|
||||||
|
int numSubFonts; /* Length of following array. */
|
||||||
|
SubFont *subFontArray; /* Array of SubFonts that have been loaded in
|
||||||
|
* order to draw/measure all the characters
|
||||||
|
* encountered by this font so far. All fonts
|
||||||
|
* start off with one SubFont initialized by
|
||||||
|
* AllocFont() from the original set of font
|
||||||
|
* attributes. Usually points to
|
||||||
|
* staticSubFonts, but may point to malloced
|
||||||
|
* space if there are lots of SubFonts. */
|
||||||
|
|
||||||
|
short size; /* Font size in pixels, constructed from font
|
||||||
|
* attributes. */
|
||||||
|
short style; /* Style bits, constructed from font
|
||||||
|
* attributes. */
|
||||||
|
} MacFont;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load the named bitmap font as a sequence of bitmaps in a display list.
|
||||||
|
* fontname may be any font recognized by Tk_GetFont.
|
||||||
|
*/
|
||||||
|
Tcl_Obj *
|
||||||
|
Togl_LoadBitmapFont(const Togl *togl, const char *fontname)
|
||||||
|
{
|
||||||
|
Tk_Font font;
|
||||||
|
Togl_BitmapFontInfo *bfi;
|
||||||
|
Tcl_Obj *obj;
|
||||||
|
|
||||||
|
#if defined(TOGL_X11)
|
||||||
|
UnixFont *unixfont;
|
||||||
|
XFontStruct *fontinfo;
|
||||||
|
#elif defined(TOGL_WGL)
|
||||||
|
WinFont *winfont;
|
||||||
|
HFONT oldFont;
|
||||||
|
TEXTMETRIC tm;
|
||||||
|
#elif defined(TOGL_AGL) || defined(TOGL_NSOPENGL)
|
||||||
|
MacFont *macfont;
|
||||||
|
#endif
|
||||||
|
int first, last, count;
|
||||||
|
GLuint fontbase;
|
||||||
|
|
||||||
|
if (!fontname) {
|
||||||
|
fontname = DEFAULT_FONTNAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
font = Tk_GetFont(togl->Interp, togl->TkWin, fontname);
|
||||||
|
if (!font) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#if defined(TOGL_X11)
|
||||||
|
unixfont = (UnixFont *) font;
|
||||||
|
fontinfo = unixfont->subFontArray->fontStructPtr;
|
||||||
|
first = fontinfo->min_char_or_byte2;
|
||||||
|
last = fontinfo->max_char_or_byte2;
|
||||||
|
#elif defined(TOGL_WGL)
|
||||||
|
winfont = (WinFont *) font;
|
||||||
|
oldFont =
|
||||||
|
(HFONT) SelectObject(togl->tglGLHdc, winfont->subFontArray->hFont);
|
||||||
|
GetTextMetrics(togl->tglGLHdc, &tm);
|
||||||
|
first = tm.tmFirstChar;
|
||||||
|
last = tm.tmLastChar;
|
||||||
|
#elif defined(TOGL_AGL) || defined(TOGL_NSOPENGL)
|
||||||
|
macfont = (MacFont *) font;
|
||||||
|
first = 10; /* don't know how to determine font range on
|
||||||
|
* Mac... */
|
||||||
|
last = 255;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (last > 255)
|
||||||
|
last = 255; /* no unicode support */
|
||||||
|
|
||||||
|
count = last - first + 1;
|
||||||
|
fontbase = glGenLists((GLuint) (last + 1));
|
||||||
|
if (fontbase == 0) {
|
||||||
|
#ifdef TOGL_WGL
|
||||||
|
SelectObject(togl->tglGLHdc, oldFont);
|
||||||
|
#endif
|
||||||
|
Tk_FreeFont(font);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#if defined(TOGL_WGL)
|
||||||
|
wglUseFontBitmaps(togl->tglGLHdc, first, count, fontbase + first);
|
||||||
|
SelectObject(togl->tglGLHdc, oldFont);
|
||||||
|
#elif defined(TOGL_X11)
|
||||||
|
glXUseXFont(fontinfo->fid, first, count, (int) fontbase + first);
|
||||||
|
#elif defined(TOGL_AGL)
|
||||||
|
/* deprecated in OS X 10.5 */
|
||||||
|
aglUseFont(togl->Ctx,
|
||||||
|
macfont->subFontArray->familyPtr->faceNum,
|
||||||
|
macfont->style, macfont->size, first, count, fontbase + first);
|
||||||
|
#elif defined(TOGL_NSOPENGL)
|
||||||
|
/* No NSOpenGL equivalent to aglUseFont(). */
|
||||||
|
#endif
|
||||||
|
Tk_FreeFont(font);
|
||||||
|
|
||||||
|
bfi = (Togl_BitmapFontInfo *) ckalloc(sizeof (Togl_BitmapFontInfo));
|
||||||
|
bfi->base = fontbase;
|
||||||
|
bfi->first = first;
|
||||||
|
bfi->last = last;
|
||||||
|
bfi->contextTag = togl->contextTag;
|
||||||
|
|
||||||
|
obj = Tcl_NewObj();
|
||||||
|
SET_BITMAP_FONT_INFO(obj) = bfi;
|
||||||
|
obj->typePtr = &Togl_BitmapFontType;
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Release the display lists which were generated by Togl_LoadBitmapFont().
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
Togl_UnloadBitmapFont(const Togl *togl, Tcl_Obj *toglfont)
|
||||||
|
{
|
||||||
|
Togl_BitmapFontInfo *bfi;
|
||||||
|
|
||||||
|
if (toglfont == NULL || toglfont->typePtr != &Togl_BitmapFontType) {
|
||||||
|
Tcl_Interp *interp = Togl_Interp(togl);
|
||||||
|
|
||||||
|
Tcl_AppendResult(interp, "font not found", NULL);
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
bfi = BITMAP_FONT_INFO(toglfont);
|
||||||
|
glDeleteLists(bfi->base, bfi->last + 1); /* match glGenLists */
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Togl_WriteObj(const Togl *togl, const Tcl_Obj *toglfont, Tcl_Obj *obj)
|
||||||
|
{
|
||||||
|
const char *str;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
str = Tcl_GetStringFromObj(obj, &len);
|
||||||
|
return Togl_WriteChars(togl, toglfont, str, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Togl_WriteChars(const Togl *togl, const Tcl_Obj *toglfont, const char *str,
|
||||||
|
int len)
|
||||||
|
{
|
||||||
|
/* TODO: assume utf8 encoding and convert to font encoding */
|
||||||
|
Togl_BitmapFontInfo *bfi;
|
||||||
|
|
||||||
|
if (toglfont == NULL || toglfont->typePtr != &Togl_BitmapFontType)
|
||||||
|
return -1;
|
||||||
|
bfi = BITMAP_FONT_INFO(toglfont);
|
||||||
|
if (Togl_ContextTag(togl) != bfi->contextTag)
|
||||||
|
return -1;
|
||||||
|
if (len == 0)
|
||||||
|
len = strlen(str);
|
||||||
|
glListBase(bfi->base);
|
||||||
|
glCallLists(len, GL_UNSIGNED_BYTE, str);
|
||||||
|
return len;
|
||||||
|
}
|
481
ng/Togl2.1/toglGLX.c
Normal file
481
ng/Togl2.1/toglGLX.c
Normal file
@ -0,0 +1,481 @@
|
|||||||
|
/* $Id: toglGLX.c,v 1.12 2009/10/22 20:40:52 gregcouch Exp $ */
|
||||||
|
|
||||||
|
/* vi:set sw=4 expandtab: */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl - a Tk OpenGL widget
|
||||||
|
*
|
||||||
|
* Copyright (C) 1996-2002 Brian Paul and Ben Bederson
|
||||||
|
* Copyright (C) 2005-2009 Greg Couch
|
||||||
|
* See the LICENSE file for copyright details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* TODO: fullscreen support */
|
||||||
|
|
||||||
|
#undef DEBUG_GLX
|
||||||
|
|
||||||
|
static PFNGLXCHOOSEFBCONFIGPROC chooseFBConfig = NULL;
|
||||||
|
static PFNGLXGETFBCONFIGATTRIBPROC getFBConfigAttrib = NULL;
|
||||||
|
static PFNGLXGETVISUALFROMFBCONFIGPROC getVisualFromFBConfig = NULL;
|
||||||
|
static PFNGLXCREATEPBUFFERPROC createPbuffer = NULL;
|
||||||
|
static PFNGLXCREATEGLXPBUFFERSGIXPROC createPbufferSGIX = NULL;
|
||||||
|
static PFNGLXDESTROYPBUFFERPROC destroyPbuffer = NULL;
|
||||||
|
static PFNGLXQUERYDRAWABLEPROC queryPbuffer = NULL;
|
||||||
|
static Bool hasMultisampling = False;
|
||||||
|
static Bool hasPbuffer = False;
|
||||||
|
|
||||||
|
struct FBInfo
|
||||||
|
{
|
||||||
|
int acceleration;
|
||||||
|
int samples;
|
||||||
|
int depth;
|
||||||
|
int colors;
|
||||||
|
GLXFBConfig fbcfg;
|
||||||
|
XVisualInfo *visInfo;
|
||||||
|
};
|
||||||
|
typedef struct FBInfo FBInfo;
|
||||||
|
|
||||||
|
static int
|
||||||
|
FBInfoCmp(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* 1. full acceleration is better
|
||||||
|
* 2. greater color bits is better
|
||||||
|
* 3. greater depth bits is better
|
||||||
|
* 4. more multisampling is better
|
||||||
|
*/
|
||||||
|
const FBInfo *x = (const FBInfo *) a;
|
||||||
|
const FBInfo *y = (const FBInfo *) b;
|
||||||
|
|
||||||
|
if (x->acceleration != y->acceleration)
|
||||||
|
return y->acceleration - x->acceleration;
|
||||||
|
if (x->colors != y->colors)
|
||||||
|
return y->colors - x->colors;
|
||||||
|
if (x->depth != y->depth)
|
||||||
|
return y->depth - x->depth;
|
||||||
|
if (x->samples != y->samples)
|
||||||
|
return y->samples - x->samples;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_GLX
|
||||||
|
static int
|
||||||
|
fatal_error(Display *dpy, XErrorEvent * event)
|
||||||
|
{
|
||||||
|
char buf[256];
|
||||||
|
|
||||||
|
XGetErrorText(dpy, event->error_code, buf, sizeof buf);
|
||||||
|
fprintf(stderr, "%s\n", buf);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static XVisualInfo *
|
||||||
|
togl_pixelFormat(Togl *togl, int scrnum)
|
||||||
|
{
|
||||||
|
int attribs[256];
|
||||||
|
int na = 0;
|
||||||
|
int i;
|
||||||
|
XVisualInfo *visinfo;
|
||||||
|
FBInfo *info;
|
||||||
|
static int loadedOpenGL = False;
|
||||||
|
|
||||||
|
if (!loadedOpenGL) {
|
||||||
|
int dummy;
|
||||||
|
int major, minor;
|
||||||
|
const char *extensions;
|
||||||
|
|
||||||
|
/* Make sure OpenGL's GLX extension supported */
|
||||||
|
if (!glXQueryExtension(togl->display, &dummy, &dummy)) {
|
||||||
|
Tcl_SetResult(togl->Interp,
|
||||||
|
TCL_STUPID "X server is missing OpenGL GLX extension",
|
||||||
|
TCL_STATIC);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadedOpenGL = True;
|
||||||
|
#ifdef DEBUG_GLX
|
||||||
|
(void) XSetErrorHandler(fatal_error);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
glXQueryVersion(togl->display, &major, &minor);
|
||||||
|
extensions = glXQueryExtensionsString(togl->display, scrnum);
|
||||||
|
|
||||||
|
if (major > 1 || (major == 1 && minor >= 3)) {
|
||||||
|
chooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)
|
||||||
|
Togl_GetProcAddr("glXChooseFBConfig");
|
||||||
|
getFBConfigAttrib = (PFNGLXGETFBCONFIGATTRIBPROC)
|
||||||
|
Togl_GetProcAddr("glXGetFBConfigAttrib");
|
||||||
|
getVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC)
|
||||||
|
Togl_GetProcAddr("glXGetVisualFromFBConfig");
|
||||||
|
createPbuffer = (PFNGLXCREATEPBUFFERPROC)
|
||||||
|
Togl_GetProcAddr("glXCreatePbuffer");
|
||||||
|
destroyPbuffer = (PFNGLXDESTROYPBUFFERPROC)
|
||||||
|
Togl_GetProcAddr("glXDestroyPbuffer");
|
||||||
|
queryPbuffer = (PFNGLXQUERYDRAWABLEPROC)
|
||||||
|
Togl_GetProcAddr("glXQueryDrawable");
|
||||||
|
if (createPbuffer && destroyPbuffer && queryPbuffer) {
|
||||||
|
hasPbuffer = True;
|
||||||
|
} else {
|
||||||
|
createPbuffer = NULL;
|
||||||
|
destroyPbuffer = NULL;
|
||||||
|
queryPbuffer = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (major == 1 && minor == 2) {
|
||||||
|
chooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)
|
||||||
|
Togl_GetProcAddr("glXChooseFBConfigSGIX");
|
||||||
|
getFBConfigAttrib = (PFNGLXGETFBCONFIGATTRIBPROC)
|
||||||
|
Togl_GetProcAddr("glXGetFBConfigAttribSGIX");
|
||||||
|
getVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC)
|
||||||
|
Togl_GetProcAddr("glXGetVisualFromFBConfigSGIX");
|
||||||
|
if (strstr(extensions, "GLX_SGIX_pbuffer") != NULL) {
|
||||||
|
createPbufferSGIX = (PFNGLXCREATEGLXPBUFFERSGIXPROC)
|
||||||
|
Togl_GetProcAddr("glXCreateGLXPbufferSGIX");
|
||||||
|
destroyPbuffer = (PFNGLXDESTROYPBUFFERPROC)
|
||||||
|
Togl_GetProcAddr("glXDestroyGLXPbufferSGIX");
|
||||||
|
queryPbuffer = (PFNGLXQUERYDRAWABLEPROC)
|
||||||
|
Togl_GetProcAddr("glXQueryGLXPbufferSGIX");
|
||||||
|
if (createPbufferSGIX && destroyPbuffer && queryPbuffer) {
|
||||||
|
hasPbuffer = True;
|
||||||
|
} else {
|
||||||
|
createPbufferSGIX = NULL;
|
||||||
|
destroyPbuffer = NULL;
|
||||||
|
queryPbuffer = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (chooseFBConfig) {
|
||||||
|
/* verify that chooseFBConfig works (workaround Mesa 6.5 bug) */
|
||||||
|
int n = 0;
|
||||||
|
GLXFBConfig *cfgs;
|
||||||
|
|
||||||
|
attribs[n++] = GLX_RENDER_TYPE;
|
||||||
|
attribs[n++] = GLX_RGBA_BIT;
|
||||||
|
attribs[n++] = None;
|
||||||
|
|
||||||
|
cfgs = chooseFBConfig(togl->display, scrnum, attribs, &n);
|
||||||
|
if (cfgs == NULL || n == 0) {
|
||||||
|
chooseFBConfig = NULL;
|
||||||
|
}
|
||||||
|
XFree(cfgs);
|
||||||
|
}
|
||||||
|
if (chooseFBConfig == NULL
|
||||||
|
|| getFBConfigAttrib == NULL || getVisualFromFBConfig == NULL) {
|
||||||
|
chooseFBConfig = NULL;
|
||||||
|
getFBConfigAttrib = NULL;
|
||||||
|
getVisualFromFBConfig = NULL;
|
||||||
|
}
|
||||||
|
if (hasPbuffer && !chooseFBConfig) {
|
||||||
|
hasPbuffer = False;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((major > 1 || (major == 1 && minor >= 4))
|
||||||
|
|| strstr(extensions, "GLX_ARB_multisample") != NULL
|
||||||
|
|| strstr(extensions, "GLX_SGIS_multisample") != NULL) {
|
||||||
|
/* Client GLX supports multisampling, but does the server? Well, we
|
||||||
|
* can always ask. */
|
||||||
|
hasMultisampling = True;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (togl->MultisampleFlag && !hasMultisampling) {
|
||||||
|
Tcl_SetResult(togl->Interp,
|
||||||
|
TCL_STUPID "multisampling not supported", TCL_STATIC);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (togl->PbufferFlag && !hasPbuffer) {
|
||||||
|
Tcl_SetResult(togl->Interp,
|
||||||
|
TCL_STUPID "pbuffers are not supported", TCL_STATIC);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Only use the newer glXGetFBConfig if there's an explicit need for it
|
||||||
|
* because it is buggy on many systems:
|
||||||
|
* (1) NVidia 96.43.07 on Linux, single-buffered windows don't work
|
||||||
|
* (2) Mesa 6.5.X and earlier fail
|
||||||
|
*/
|
||||||
|
if (chooseFBConfig) {
|
||||||
|
/* have new glXGetFBConfig! */
|
||||||
|
int count;
|
||||||
|
GLXFBConfig *cfgs;
|
||||||
|
|
||||||
|
attribs[na++] = GLX_RENDER_TYPE;
|
||||||
|
if (togl->RgbaFlag) {
|
||||||
|
/* RGB[A] mode */
|
||||||
|
attribs[na++] = GLX_RGBA_BIT;
|
||||||
|
attribs[na++] = GLX_RED_SIZE;
|
||||||
|
attribs[na++] = togl->RgbaRed;
|
||||||
|
attribs[na++] = GLX_GREEN_SIZE;
|
||||||
|
attribs[na++] = togl->RgbaGreen;
|
||||||
|
attribs[na++] = GLX_BLUE_SIZE;
|
||||||
|
attribs[na++] = togl->RgbaBlue;
|
||||||
|
if (togl->AlphaFlag) {
|
||||||
|
attribs[na++] = GLX_ALPHA_SIZE;
|
||||||
|
attribs[na++] = togl->AlphaSize;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Color index mode */
|
||||||
|
attribs[na++] = GLX_COLOR_INDEX_BIT;
|
||||||
|
attribs[na++] = GLX_BUFFER_SIZE;
|
||||||
|
attribs[na++] = 1;
|
||||||
|
}
|
||||||
|
if (togl->DepthFlag) {
|
||||||
|
attribs[na++] = GLX_DEPTH_SIZE;
|
||||||
|
attribs[na++] = togl->DepthSize;
|
||||||
|
}
|
||||||
|
if (togl->DoubleFlag) {
|
||||||
|
attribs[na++] = GLX_DOUBLEBUFFER;
|
||||||
|
attribs[na++] = True;
|
||||||
|
}
|
||||||
|
if (togl->StencilFlag) {
|
||||||
|
attribs[na++] = GLX_STENCIL_SIZE;
|
||||||
|
attribs[na++] = togl->StencilSize;
|
||||||
|
}
|
||||||
|
if (togl->AccumFlag) {
|
||||||
|
attribs[na++] = GLX_ACCUM_RED_SIZE;
|
||||||
|
attribs[na++] = togl->AccumRed;
|
||||||
|
attribs[na++] = GLX_ACCUM_GREEN_SIZE;
|
||||||
|
attribs[na++] = togl->AccumGreen;
|
||||||
|
attribs[na++] = GLX_ACCUM_BLUE_SIZE;
|
||||||
|
attribs[na++] = togl->AccumBlue;
|
||||||
|
if (togl->AlphaFlag) {
|
||||||
|
attribs[na++] = GLX_ACCUM_ALPHA_SIZE;
|
||||||
|
attribs[na++] = togl->AccumAlpha;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (togl->Stereo == TOGL_STEREO_NATIVE) {
|
||||||
|
attribs[na++] = GLX_STEREO;
|
||||||
|
attribs[na++] = True;
|
||||||
|
}
|
||||||
|
if (togl->MultisampleFlag) {
|
||||||
|
attribs[na++] = GLX_SAMPLE_BUFFERS_ARB;
|
||||||
|
attribs[na++] = 1;
|
||||||
|
attribs[na++] = GLX_SAMPLES_ARB;
|
||||||
|
attribs[na++] = 2;
|
||||||
|
}
|
||||||
|
if (togl->PbufferFlag) {
|
||||||
|
attribs[na++] = GLX_DRAWABLE_TYPE;
|
||||||
|
attribs[na++] = GLX_WINDOW_BIT | GLX_PBUFFER_BIT;
|
||||||
|
}
|
||||||
|
if (togl->AuxNumber != 0) {
|
||||||
|
attribs[na++] = GLX_AUX_BUFFERS;
|
||||||
|
attribs[na++] = togl->AuxNumber;
|
||||||
|
}
|
||||||
|
attribs[na++] = None;
|
||||||
|
|
||||||
|
cfgs = chooseFBConfig(togl->display, scrnum, attribs, &count);
|
||||||
|
if (cfgs == NULL || count == 0) {
|
||||||
|
Tcl_SetResult(togl->Interp,
|
||||||
|
TCL_STUPID "couldn't choose pixel format", TCL_STATIC);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Pick best format
|
||||||
|
*/
|
||||||
|
info = (FBInfo *) malloc(count * sizeof (FBInfo));
|
||||||
|
for (i = 0; i != count; ++i) {
|
||||||
|
info[i].visInfo = getVisualFromFBConfig(togl->display, cfgs[i]);
|
||||||
|
info[i].fbcfg = cfgs[i];
|
||||||
|
getFBConfigAttrib(togl->display, cfgs[i], GLX_CONFIG_CAVEAT,
|
||||||
|
&info[i].acceleration);
|
||||||
|
getFBConfigAttrib(togl->display, cfgs[i], GLX_BUFFER_SIZE,
|
||||||
|
&info[i].colors);
|
||||||
|
getFBConfigAttrib(togl->display, cfgs[i], GLX_DEPTH_SIZE,
|
||||||
|
&info[i].depth);
|
||||||
|
getFBConfigAttrib(togl->display, cfgs[i], GLX_SAMPLES,
|
||||||
|
&info[i].samples);
|
||||||
|
/* revise attributes so larger is better */
|
||||||
|
info[i].acceleration = -(info[i].acceleration - GLX_NONE);
|
||||||
|
if (!togl->DepthFlag)
|
||||||
|
info[i].depth = -info[i].depth;
|
||||||
|
if (!togl->MultisampleFlag)
|
||||||
|
info[i].samples = -info[i].samples;
|
||||||
|
}
|
||||||
|
qsort(info, count, sizeof info[0], FBInfoCmp);
|
||||||
|
|
||||||
|
togl->fbcfg = info[0].fbcfg;
|
||||||
|
visinfo = info[0].visInfo;
|
||||||
|
for (i = 1; i != count; ++i)
|
||||||
|
XFree(info[i].visInfo);
|
||||||
|
free(info);
|
||||||
|
XFree(cfgs);
|
||||||
|
return visinfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* use original glXChooseVisual */
|
||||||
|
|
||||||
|
attribs[na++] = GLX_USE_GL;
|
||||||
|
if (togl->RgbaFlag) {
|
||||||
|
/* RGB[A] mode */
|
||||||
|
attribs[na++] = GLX_RGBA;
|
||||||
|
attribs[na++] = GLX_RED_SIZE;
|
||||||
|
attribs[na++] = togl->RgbaRed;
|
||||||
|
attribs[na++] = GLX_GREEN_SIZE;
|
||||||
|
attribs[na++] = togl->RgbaGreen;
|
||||||
|
attribs[na++] = GLX_BLUE_SIZE;
|
||||||
|
attribs[na++] = togl->RgbaBlue;
|
||||||
|
if (togl->AlphaFlag) {
|
||||||
|
attribs[na++] = GLX_ALPHA_SIZE;
|
||||||
|
attribs[na++] = togl->AlphaSize;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Color index mode */
|
||||||
|
attribs[na++] = GLX_BUFFER_SIZE;
|
||||||
|
attribs[na++] = 1;
|
||||||
|
}
|
||||||
|
if (togl->DepthFlag) {
|
||||||
|
attribs[na++] = GLX_DEPTH_SIZE;
|
||||||
|
attribs[na++] = togl->DepthSize;
|
||||||
|
}
|
||||||
|
if (togl->DoubleFlag) {
|
||||||
|
attribs[na++] = GLX_DOUBLEBUFFER;
|
||||||
|
}
|
||||||
|
if (togl->StencilFlag) {
|
||||||
|
attribs[na++] = GLX_STENCIL_SIZE;
|
||||||
|
attribs[na++] = togl->StencilSize;
|
||||||
|
}
|
||||||
|
if (togl->AccumFlag) {
|
||||||
|
attribs[na++] = GLX_ACCUM_RED_SIZE;
|
||||||
|
attribs[na++] = togl->AccumRed;
|
||||||
|
attribs[na++] = GLX_ACCUM_GREEN_SIZE;
|
||||||
|
attribs[na++] = togl->AccumGreen;
|
||||||
|
attribs[na++] = GLX_ACCUM_BLUE_SIZE;
|
||||||
|
attribs[na++] = togl->AccumBlue;
|
||||||
|
if (togl->AlphaFlag) {
|
||||||
|
attribs[na++] = GLX_ACCUM_ALPHA_SIZE;
|
||||||
|
attribs[na++] = togl->AccumAlpha;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (togl->Stereo == TOGL_STEREO_NATIVE) {
|
||||||
|
attribs[na++] = GLX_STEREO;
|
||||||
|
}
|
||||||
|
if (togl->AuxNumber != 0) {
|
||||||
|
attribs[na++] = GLX_AUX_BUFFERS;
|
||||||
|
attribs[na++] = togl->AuxNumber;
|
||||||
|
}
|
||||||
|
attribs[na++] = None;
|
||||||
|
|
||||||
|
visinfo = glXChooseVisual(togl->display, scrnum, attribs);
|
||||||
|
if (visinfo == NULL) {
|
||||||
|
Tcl_SetResult(togl->Interp,
|
||||||
|
TCL_STUPID "couldn't choose pixel format", TCL_STATIC);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return visinfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
togl_describePixelFormat(Togl *togl)
|
||||||
|
{
|
||||||
|
int tmp = 0;
|
||||||
|
|
||||||
|
/* fill in flags normally passed in that affect behavior */
|
||||||
|
(void) glXGetConfig(togl->display, togl->VisInfo, GLX_RGBA,
|
||||||
|
&togl->RgbaFlag);
|
||||||
|
(void) glXGetConfig(togl->display, togl->VisInfo, GLX_DOUBLEBUFFER,
|
||||||
|
&togl->DoubleFlag);
|
||||||
|
(void) glXGetConfig(togl->display, togl->VisInfo, GLX_DEPTH_SIZE, &tmp);
|
||||||
|
togl->DepthFlag = (tmp != 0);
|
||||||
|
(void) glXGetConfig(togl->display, togl->VisInfo, GLX_ACCUM_RED_SIZE, &tmp);
|
||||||
|
togl->AccumFlag = (tmp != 0);
|
||||||
|
(void) glXGetConfig(togl->display, togl->VisInfo, GLX_ALPHA_SIZE, &tmp);
|
||||||
|
togl->AlphaFlag = (tmp != 0);
|
||||||
|
(void) glXGetConfig(togl->display, togl->VisInfo, GLX_STENCIL_SIZE, &tmp);
|
||||||
|
togl->StencilFlag = (tmp != 0);
|
||||||
|
(void) glXGetConfig(togl->display, togl->VisInfo, GLX_STEREO, &tmp);
|
||||||
|
togl->Stereo = tmp ? TOGL_STEREO_NATIVE : TOGL_STEREO_NONE;
|
||||||
|
if (hasMultisampling) {
|
||||||
|
(void) glXGetConfig(togl->display, togl->VisInfo, GLX_SAMPLES, &tmp);
|
||||||
|
togl->MultisampleFlag = (tmp != 0);
|
||||||
|
}
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Tcl_ThreadDataKey togl_XError;
|
||||||
|
struct ErrorData
|
||||||
|
{
|
||||||
|
int error_code;
|
||||||
|
XErrorHandler prevHandler;
|
||||||
|
};
|
||||||
|
typedef struct ErrorData ErrorData;
|
||||||
|
|
||||||
|
static int
|
||||||
|
togl_HandleXError(Display *dpy, XErrorEvent * event)
|
||||||
|
{
|
||||||
|
ErrorData *data = Tcl_GetThreadData(&togl_XError, (int) sizeof (ErrorData));
|
||||||
|
|
||||||
|
data->error_code = event->error_code;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
togl_SetupXErrorHandler()
|
||||||
|
{
|
||||||
|
ErrorData *data = Tcl_GetThreadData(&togl_XError, (int) sizeof (ErrorData));
|
||||||
|
|
||||||
|
data->error_code = Success; /* 0 */
|
||||||
|
data->prevHandler = XSetErrorHandler(togl_HandleXError);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
togl_CheckForXError(const Togl *togl)
|
||||||
|
{
|
||||||
|
ErrorData *data = Tcl_GetThreadData(&togl_XError, (int) sizeof (ErrorData));
|
||||||
|
|
||||||
|
XSync(togl->display, False);
|
||||||
|
(void) XSetErrorHandler(data->prevHandler);
|
||||||
|
return data->error_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GLXPbuffer
|
||||||
|
togl_createPbuffer(Togl *togl)
|
||||||
|
{
|
||||||
|
int attribs[32];
|
||||||
|
int na = 0;
|
||||||
|
GLXPbuffer pbuf;
|
||||||
|
|
||||||
|
togl_SetupXErrorHandler();
|
||||||
|
if (togl->LargestPbufferFlag) {
|
||||||
|
attribs[na++] = GLX_LARGEST_PBUFFER;
|
||||||
|
attribs[na++] = True;
|
||||||
|
}
|
||||||
|
attribs[na++] = GLX_PRESERVED_CONTENTS;
|
||||||
|
attribs[na++] = True;
|
||||||
|
if (createPbuffer) {
|
||||||
|
attribs[na++] = GLX_PBUFFER_WIDTH;
|
||||||
|
attribs[na++] = togl->Width;
|
||||||
|
attribs[na++] = GLX_PBUFFER_HEIGHT;
|
||||||
|
attribs[na++] = togl->Width;
|
||||||
|
attribs[na++] = None;
|
||||||
|
pbuf = createPbuffer(togl->display, togl->fbcfg, attribs);
|
||||||
|
} else {
|
||||||
|
attribs[na++] = None;
|
||||||
|
pbuf = createPbufferSGIX(togl->display, togl->fbcfg, togl->Width,
|
||||||
|
togl->Height, attribs);
|
||||||
|
}
|
||||||
|
if (togl_CheckForXError(togl) || pbuf == None) {
|
||||||
|
Tcl_SetResult(togl->Interp,
|
||||||
|
TCL_STUPID "unable to allocate pbuffer", TCL_STATIC);
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
if (pbuf && togl->LargestPbufferFlag) {
|
||||||
|
int tmp;
|
||||||
|
|
||||||
|
queryPbuffer(togl->display, pbuf, GLX_WIDTH, &tmp);
|
||||||
|
if (tmp != 0)
|
||||||
|
togl->Width = tmp;
|
||||||
|
queryPbuffer(togl->display, pbuf, GLX_HEIGHT, &tmp);
|
||||||
|
if (tmp != 0)
|
||||||
|
togl->Height = tmp;
|
||||||
|
}
|
||||||
|
return pbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
togl_destroyPbuffer(Togl *togl)
|
||||||
|
{
|
||||||
|
destroyPbuffer(togl->display, togl->pbuf);
|
||||||
|
}
|
61
ng/Togl2.1/toglProcAddr.c
Normal file
61
ng/Togl2.1/toglProcAddr.c
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/* $Id */
|
||||||
|
|
||||||
|
/* vi:set sw=4: */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl - a Tk OpenGL widget
|
||||||
|
*
|
||||||
|
* Copyright (C) 1996-2002 Brian Paul and Ben Bederson
|
||||||
|
* Copyright (C) 2005-2009 Greg Couch
|
||||||
|
* See the LICENSE file for copyright details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "togl.h"
|
||||||
|
|
||||||
|
#if defined(TOGL_OSMESA) || defined(TOGL_WGL)
|
||||||
|
/* nothing extra to include */
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
# include <mach-o/dyld.h>
|
||||||
|
#else
|
||||||
|
# if !defined(TOGL_X11) || !defined(GLX_VERSION_1_4)
|
||||||
|
# include <dlfcn.h>
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Togl_FuncPtr
|
||||||
|
Togl_GetProcAddr(const char *funcname)
|
||||||
|
{
|
||||||
|
#if defined(TOGL_OSMESA)
|
||||||
|
return (Togl_FuncPtr) OSMesaGetProcAddress(funcname);
|
||||||
|
#elif defined(TOGL_WGL)
|
||||||
|
return (Togl_FuncPtr) wglGetProcAddress(funcname);
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
char buf[256];
|
||||||
|
|
||||||
|
snprintf(buf, sizeof buf - 1, "_%s", funcname);
|
||||||
|
buf[sizeof buf - 1] = '\0';
|
||||||
|
if (NSIsSymbolNameDefined(buf)) {
|
||||||
|
NSSymbol nssym;
|
||||||
|
|
||||||
|
nssym = NSLookupAndBindSymbol(buf);
|
||||||
|
if (nssym)
|
||||||
|
return (Togl_FuncPtr) NSAddressOfSymbol(nssym);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
#else
|
||||||
|
# if defined(TOGL_X11) && defined(GLX_VERSION_1_4)
|
||||||
|
/* Strictly speaking, we can only call glXGetProcAddress if glXQueryVersion
|
||||||
|
* says we're using version 1.4 or later. */
|
||||||
|
return (Togl_FuncPtr) glXGetProcAddress(funcname);
|
||||||
|
# else
|
||||||
|
/* Linux, IRIX, OSF/1, ? */
|
||||||
|
static void *dlHandle = NULL;
|
||||||
|
|
||||||
|
if (dlHandle == NULL)
|
||||||
|
dlHandle = dlopen(NULL, RTLD_LAZY);
|
||||||
|
/* Strictly speaking, the following cast of a data pointer to a function
|
||||||
|
* pointer is not legal in ISO C, but we don't have any choice. */
|
||||||
|
return (Togl_FuncPtr) dlsym(dlHandle, funcname);
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
}
|
69
ng/Togl2.1/toglStubInit.c
Executable file
69
ng/Togl2.1/toglStubInit.c
Executable file
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Togl - a Tk OpenGL widget
|
||||||
|
*
|
||||||
|
* Copyright (C) 1996-2002 Brian Paul and Ben Bederson
|
||||||
|
* Copyright (C) 2005-2009 Greg Couch
|
||||||
|
* See the LICENSE file for copyright details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "togl.h"
|
||||||
|
|
||||||
|
extern const ToglStubs toglStubs;
|
||||||
|
|
||||||
|
/* !BEGIN!: Do not edit below this line. */
|
||||||
|
|
||||||
|
const ToglStubs toglStubs = {
|
||||||
|
TCL_STUB_MAGIC,
|
||||||
|
NULL,
|
||||||
|
Togl_Init, /* 0 */
|
||||||
|
Togl_MakeCurrent, /* 1 */
|
||||||
|
Togl_PostRedisplay, /* 2 */
|
||||||
|
Togl_SwapBuffers, /* 3 */
|
||||||
|
Togl_Ident, /* 4 */
|
||||||
|
Togl_Width, /* 5 */
|
||||||
|
Togl_Height, /* 6 */
|
||||||
|
Togl_Interp, /* 7 */
|
||||||
|
Togl_TkWin, /* 8 */
|
||||||
|
Togl_CommandName, /* 9 */
|
||||||
|
Togl_AllocColor, /* 10 */
|
||||||
|
Togl_FreeColor, /* 11 */
|
||||||
|
Togl_SetColor, /* 12 */
|
||||||
|
Togl_LoadBitmapFont, /* 13 */
|
||||||
|
Togl_UnloadBitmapFont, /* 14 */
|
||||||
|
Togl_UseLayer, /* 15 */
|
||||||
|
Togl_ShowOverlay, /* 16 */
|
||||||
|
Togl_HideOverlay, /* 17 */
|
||||||
|
Togl_PostOverlayRedisplay, /* 18 */
|
||||||
|
Togl_ExistsOverlay, /* 19 */
|
||||||
|
Togl_GetOverlayTransparentValue, /* 20 */
|
||||||
|
Togl_IsMappedOverlay, /* 21 */
|
||||||
|
Togl_AllocColorOverlay, /* 22 */
|
||||||
|
Togl_FreeColorOverlay, /* 23 */
|
||||||
|
Togl_GetClientData, /* 24 */
|
||||||
|
Togl_SetClientData, /* 25 */
|
||||||
|
Togl_DrawBuffer, /* 26 */
|
||||||
|
Togl_Clear, /* 27 */
|
||||||
|
Togl_Frustum, /* 28 */
|
||||||
|
Togl_GetToglFromObj, /* 29 */
|
||||||
|
Togl_TakePhoto, /* 30 */
|
||||||
|
Togl_GetProcAddr, /* 31 */
|
||||||
|
Togl_GetToglFromName, /* 32 */
|
||||||
|
Togl_SwapInterval, /* 33 */
|
||||||
|
Togl_Ortho, /* 34 */
|
||||||
|
Togl_NumEyes, /* 35 */
|
||||||
|
Togl_ContextTag, /* 36 */
|
||||||
|
Togl_UpdatePending, /* 37 */
|
||||||
|
Togl_WriteObj, /* 38 */
|
||||||
|
Togl_WriteChars, /* 39 */
|
||||||
|
Togl_HasRGBA, /* 40 */
|
||||||
|
Togl_IsDoubleBuffered, /* 41 */
|
||||||
|
Togl_HasDepthBuffer, /* 42 */
|
||||||
|
Togl_HasAccumulationBuffer, /* 43 */
|
||||||
|
Togl_HasDestinationAlpha, /* 44 */
|
||||||
|
Togl_HasStencilBuffer, /* 45 */
|
||||||
|
Togl_StereoMode, /* 46 */
|
||||||
|
Togl_HasMultisample, /* 47 */
|
||||||
|
Togl_CopyContext, /* 48 */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* !END!: Do not edit above this line. */
|
59
ng/Togl2.1/toglStubLib.c
Normal file
59
ng/Togl2.1/toglStubLib.c
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
#ifndef USE_TCL_STUBS
|
||||||
|
# define USE_TCL_STUBS
|
||||||
|
#endif
|
||||||
|
#undef USE_TCL_STUB_PROCS
|
||||||
|
#ifndef USE_TK_STUBS
|
||||||
|
# define USE_TK_STUBS
|
||||||
|
#endif
|
||||||
|
#undef USE_TK_STUB_PROCS
|
||||||
|
|
||||||
|
#include "togl.h"
|
||||||
|
|
||||||
|
const ToglStubs *toglStubsPtr;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Ensure that Togl_InitStubs is built as an exported symbol. The other stub
|
||||||
|
** functions should be built as non-exported symbols.
|
||||||
|
*/
|
||||||
|
#undef TCL_STORAGE_CLASS
|
||||||
|
#define TCL_STORAGE_CLASS DLLEXPORT
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl_InitStubs --
|
||||||
|
*
|
||||||
|
* Checks that the correct version of Togl is loaded and that it
|
||||||
|
* supports stubs. It then initialises the stub table pointers.
|
||||||
|
*
|
||||||
|
* Results:
|
||||||
|
* The actual version of Togl that satisfies the request, or
|
||||||
|
* NULL to indicate that an error occurred.
|
||||||
|
*
|
||||||
|
* Side effects:
|
||||||
|
* sets the stub table pointer.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef Togl_InitStubs
|
||||||
|
# undef Togl_InitStubs
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char *
|
||||||
|
Togl_InitStubs(Tcl_Interp *interp, const char *version, int exact)
|
||||||
|
{
|
||||||
|
const char *actualVersion;
|
||||||
|
|
||||||
|
actualVersion = Tcl_PkgRequireEx(interp, "Togl", version, exact,
|
||||||
|
(ClientData *) &toglStubsPtr);
|
||||||
|
if (!actualVersion) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!toglStubsPtr) {
|
||||||
|
Tcl_SetResult(interp,
|
||||||
|
"This implementation of Togl does not support stubs",
|
||||||
|
TCL_STATIC);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return actualVersion;
|
||||||
|
}
|
595
ng/Togl2.1/toglWGL.c
Normal file
595
ng/Togl2.1/toglWGL.c
Normal file
@ -0,0 +1,595 @@
|
|||||||
|
/* $Id: toglWGL.c,v 1.8 2009/12/23 21:50:49 gregcouch Exp $ */
|
||||||
|
|
||||||
|
/* vi:set sw=4 expandtab: */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Togl - a Tk OpenGL widget
|
||||||
|
*
|
||||||
|
* Copyright (C) 1996-2002 Brian Paul and Ben Bederson
|
||||||
|
* Copyright (C) 2005-2009 Greg Couch
|
||||||
|
* See the LICENSE file for copyright details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* TODO: fullscreen support */
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#include <wingdi.h>
|
||||||
|
#include <tk.h>
|
||||||
|
#include <tkPlatDecls.h>
|
||||||
|
#include <GL/wglext.h>
|
||||||
|
|
||||||
|
#ifndef PFD_SUPPORT_COMPOSITION
|
||||||
|
/* for Vista -- not needed because we don't use PFD_SUPPORT_GDI/BITMAP */
|
||||||
|
# define PFD_SUPPORT_COMPOSITION 0x00008000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* TODO: move these statics into global structure */
|
||||||
|
static PFNWGLGETEXTENSIONSSTRINGARBPROC getExtensionsString = NULL;
|
||||||
|
static PFNWGLCHOOSEPIXELFORMATARBPROC choosePixelFormat;
|
||||||
|
static PFNWGLGETPIXELFORMATATTRIBIVARBPROC getPixelFormatAttribiv;
|
||||||
|
static PFNWGLCREATEPBUFFERARBPROC createPbuffer = NULL;
|
||||||
|
static PFNWGLDESTROYPBUFFERARBPROC destroyPbuffer = NULL;
|
||||||
|
static PFNWGLGETPBUFFERDCARBPROC getPbufferDC = NULL;
|
||||||
|
static PFNWGLRELEASEPBUFFERDCARBPROC releasePbufferDC = NULL;
|
||||||
|
static PFNWGLQUERYPBUFFERARBPROC queryPbuffer = NULL;
|
||||||
|
static int hasMultisampling = FALSE;
|
||||||
|
static int hasPbuffer = FALSE;
|
||||||
|
static int hasARBPbuffer = FALSE;
|
||||||
|
|
||||||
|
static HWND
|
||||||
|
toglCreateTestWindow(HWND parent)
|
||||||
|
{
|
||||||
|
static char ClassName[] = "ToglTestWindow";
|
||||||
|
WNDCLASS wc;
|
||||||
|
HINSTANCE instance = GetModuleHandle(NULL);
|
||||||
|
HWND wnd;
|
||||||
|
HDC dc;
|
||||||
|
PIXELFORMATDESCRIPTOR pfd;
|
||||||
|
int pixelFormat;
|
||||||
|
|
||||||
|
wc.style = CS_OWNDC;
|
||||||
|
wc.lpfnWndProc = DefWindowProc;
|
||||||
|
wc.cbClsExtra = 0;
|
||||||
|
wc.cbWndExtra = 0;
|
||||||
|
wc.hInstance = instance;
|
||||||
|
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
|
||||||
|
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
|
wc.hbrBackground = NULL;
|
||||||
|
wc.lpszMenuName = NULL;
|
||||||
|
wc.lpszClassName = ClassName;
|
||||||
|
if (!RegisterClass(&wc)) {
|
||||||
|
DWORD err = GetLastError();
|
||||||
|
|
||||||
|
if (err != ERROR_CLASS_ALREADY_EXISTS) {
|
||||||
|
fprintf(stderr, "Unable to register Togl Test Window class\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wnd = CreateWindow(ClassName, "test OpenGL capabilities",
|
||||||
|
WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
|
||||||
|
0, 0, 1, 1, parent, NULL, instance, NULL);
|
||||||
|
if (wnd == NULL) {
|
||||||
|
fprintf(stderr, "Unable to create temporary OpenGL window\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
dc = GetDC(wnd);
|
||||||
|
|
||||||
|
memset(&pfd, 0, sizeof pfd);
|
||||||
|
pfd.nSize = sizeof pfd;
|
||||||
|
pfd.nVersion = 1;
|
||||||
|
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
|
||||||
|
pfd.iPixelType = PFD_TYPE_RGBA;
|
||||||
|
pfd.cColorBits = 3;
|
||||||
|
pfd.iLayerType = PFD_MAIN_PLANE;
|
||||||
|
pixelFormat = ChoosePixelFormat(dc, &pfd);
|
||||||
|
if (pixelFormat == 0) {
|
||||||
|
fprintf(stderr, "Unable to choose simple pixel format\n");
|
||||||
|
ReleaseDC(wnd, dc);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (!SetPixelFormat(dc, pixelFormat, &pfd)) {
|
||||||
|
fprintf(stderr, "Unable to set simple pixel format\n");
|
||||||
|
ReleaseDC(wnd, dc);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowWindow(wnd, SW_HIDE); // make sure it's hidden
|
||||||
|
ReleaseDC(wnd, dc);
|
||||||
|
return wnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct FBInfo
|
||||||
|
{
|
||||||
|
int stereo;
|
||||||
|
int acceleration;
|
||||||
|
int colors;
|
||||||
|
int depth;
|
||||||
|
int samples;
|
||||||
|
int pixelFormat;
|
||||||
|
};
|
||||||
|
typedef struct FBInfo FBInfo;
|
||||||
|
static int FBAttribs[] = {
|
||||||
|
/* must match order in FBInfo structure */
|
||||||
|
WGL_STEREO_ARB,
|
||||||
|
WGL_ACCELERATION_ARB,
|
||||||
|
WGL_COLOR_BITS_ARB,
|
||||||
|
WGL_DEPTH_BITS_ARB,
|
||||||
|
WGL_SAMPLES_ARB,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define NUM_FBAttribs (sizeof FBAttribs / sizeof FBAttribs[0])
|
||||||
|
|
||||||
|
static int
|
||||||
|
FBInfoCmp(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* 1. stereo is better
|
||||||
|
* 2. full acceleration is better
|
||||||
|
* 3. greater color bits is better
|
||||||
|
* 4. greater depth bits is better
|
||||||
|
* 5. more multisampling is better
|
||||||
|
*/
|
||||||
|
const FBInfo *x = (const FBInfo *) a;
|
||||||
|
const FBInfo *y = (const FBInfo *) b;
|
||||||
|
|
||||||
|
if (x->stereo != y->stereo)
|
||||||
|
return y->stereo - x->stereo;
|
||||||
|
if (x->acceleration != y->acceleration)
|
||||||
|
return y->acceleration - x->acceleration;
|
||||||
|
if (x->colors != y->colors)
|
||||||
|
return y->colors - x->colors;
|
||||||
|
if (x->depth != y->depth)
|
||||||
|
return y->depth - x->depth;
|
||||||
|
if (x->samples != y->samples)
|
||||||
|
return y->samples - x->samples;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
togl_pixelFormat(Togl *togl, HWND hwnd)
|
||||||
|
{
|
||||||
|
/* return 0 when pixel format is unavailable. */
|
||||||
|
int pixelformat = 0;
|
||||||
|
static int loadedOpenGL = FALSE;
|
||||||
|
int formats[256];
|
||||||
|
UINT numFormats;
|
||||||
|
FBInfo *info;
|
||||||
|
UINT i;
|
||||||
|
int attribs[128];
|
||||||
|
int na = 0;
|
||||||
|
|
||||||
|
if (!loadedOpenGL) {
|
||||||
|
HWND test = NULL;
|
||||||
|
HDC dc;
|
||||||
|
HGLRC rc;
|
||||||
|
|
||||||
|
if (wglGetCurrentContext() != NULL) {
|
||||||
|
dc = wglGetCurrentDC();
|
||||||
|
} else {
|
||||||
|
/* HWND hwnd = Tk_GetHWND(Tk_WindowId(togl->TkWin)); */
|
||||||
|
|
||||||
|
test = toglCreateTestWindow(hwnd);
|
||||||
|
if (test == NULL) {
|
||||||
|
Tcl_SetResult(togl->Interp,
|
||||||
|
TCL_STUPID "can't create dummy OpenGL window",
|
||||||
|
TCL_STATIC);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
dc = GetDC(test);
|
||||||
|
rc = wglCreateContext(dc);
|
||||||
|
wglMakeCurrent(dc, rc);
|
||||||
|
}
|
||||||
|
loadedOpenGL = TRUE;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now that we have an OpenGL window, we can initialize all
|
||||||
|
* OpenGL information and figure out if multisampling is supported.
|
||||||
|
*/
|
||||||
|
getExtensionsString = (PFNWGLGETEXTENSIONSSTRINGARBPROC)
|
||||||
|
wglGetProcAddress("wglGetExtensionsStringARB");
|
||||||
|
if (getExtensionsString == NULL)
|
||||||
|
getExtensionsString = (PFNWGLGETEXTENSIONSSTRINGARBPROC)
|
||||||
|
wglGetProcAddress("wglGetExtensionsStringEXT");
|
||||||
|
if (getExtensionsString) {
|
||||||
|
const char *extensions = getExtensionsString(dc);
|
||||||
|
|
||||||
|
if (strstr(extensions, "WGL_ARB_multisample") != NULL
|
||||||
|
|| strstr(extensions, "WGL_EXT_multisample") != NULL)
|
||||||
|
hasMultisampling = TRUE;
|
||||||
|
|
||||||
|
if (strstr(extensions, "WGL_ARB_pixel_format") != NULL) {
|
||||||
|
choosePixelFormat = (PFNWGLCHOOSEPIXELFORMATARBPROC)
|
||||||
|
wglGetProcAddress("wglChoosePixelFormatARB");
|
||||||
|
getPixelFormatAttribiv = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)
|
||||||
|
wglGetProcAddress("wglGetPixelFormatAttribivARB");
|
||||||
|
if (choosePixelFormat == NULL || getPixelFormatAttribiv == NULL) {
|
||||||
|
choosePixelFormat = NULL;
|
||||||
|
getPixelFormatAttribiv = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (choosePixelFormat == NULL
|
||||||
|
&& strstr(extensions, "WGL_EXT_pixel_format") != NULL) {
|
||||||
|
choosePixelFormat = (PFNWGLCHOOSEPIXELFORMATARBPROC)
|
||||||
|
wglGetProcAddress("wglChoosePixelFormatEXT");
|
||||||
|
getPixelFormatAttribiv = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)
|
||||||
|
wglGetProcAddress("wglGetPixelFormatAttribivEXT");
|
||||||
|
if (choosePixelFormat == NULL || getPixelFormatAttribiv == NULL) {
|
||||||
|
choosePixelFormat = NULL;
|
||||||
|
getPixelFormatAttribiv = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (createPbuffer == NULL
|
||||||
|
&& strstr(extensions, "WGL_ARB_pbuffer") != NULL) {
|
||||||
|
createPbuffer = (PFNWGLCREATEPBUFFERARBPROC)
|
||||||
|
wglGetProcAddress("wglCreatePbufferARB");
|
||||||
|
destroyPbuffer = (PFNWGLDESTROYPBUFFERARBPROC)
|
||||||
|
wglGetProcAddress("wglDestroyPbufferARB");
|
||||||
|
getPbufferDC = (PFNWGLGETPBUFFERDCARBPROC)
|
||||||
|
wglGetProcAddress("wglGetPbufferDCARB");
|
||||||
|
releasePbufferDC = (PFNWGLRELEASEPBUFFERDCARBPROC)
|
||||||
|
wglGetProcAddress("wglReleasePbufferDCARB");
|
||||||
|
queryPbuffer = (PFNWGLQUERYPBUFFERARBPROC)
|
||||||
|
wglGetProcAddress("wglQueryPbufferARB");
|
||||||
|
if (createPbuffer == NULL || destroyPbuffer == NULL
|
||||||
|
|| getPbufferDC == NULL || releasePbufferDC == NULL
|
||||||
|
|| queryPbuffer == NULL) {
|
||||||
|
createPbuffer = NULL;
|
||||||
|
destroyPbuffer = NULL;
|
||||||
|
getPbufferDC = NULL;
|
||||||
|
releasePbufferDC = NULL;
|
||||||
|
queryPbuffer = NULL;
|
||||||
|
} else {
|
||||||
|
hasPbuffer = TRUE;
|
||||||
|
hasARBPbuffer = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (createPbuffer == NULL
|
||||||
|
&& strstr(extensions, "WGL_EXT_pbuffer") != NULL) {
|
||||||
|
createPbuffer = (PFNWGLCREATEPBUFFERARBPROC)
|
||||||
|
wglGetProcAddress("wglCreatePbufferEXT");
|
||||||
|
destroyPbuffer = (PFNWGLDESTROYPBUFFERARBPROC)
|
||||||
|
wglGetProcAddress("wglDestroyPbufferEXT");
|
||||||
|
getPbufferDC = (PFNWGLGETPBUFFERDCARBPROC)
|
||||||
|
wglGetProcAddress("wglGetPbufferDCEXT");
|
||||||
|
releasePbufferDC = (PFNWGLRELEASEPBUFFERDCARBPROC)
|
||||||
|
wglGetProcAddress("wglReleasePbufferDCEXT");
|
||||||
|
queryPbuffer = (PFNWGLQUERYPBUFFERARBPROC)
|
||||||
|
wglGetProcAddress("wglQueryPbufferEXT");
|
||||||
|
if (createPbuffer == NULL || destroyPbuffer == NULL
|
||||||
|
|| getPbufferDC == NULL || releasePbufferDC == NULL
|
||||||
|
|| queryPbuffer == NULL) {
|
||||||
|
createPbuffer = NULL;
|
||||||
|
destroyPbuffer = NULL;
|
||||||
|
getPbufferDC = NULL;
|
||||||
|
releasePbufferDC = NULL;
|
||||||
|
queryPbuffer = NULL;
|
||||||
|
} else {
|
||||||
|
hasPbuffer = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* No need to confirm multisampling is in glGetString(GL_EXTENSIONS)
|
||||||
|
* because OpenGL driver is local */
|
||||||
|
|
||||||
|
if (test != NULL) {
|
||||||
|
/* cleanup by removing temporary OpenGL window */
|
||||||
|
wglMakeCurrent(NULL, NULL);
|
||||||
|
wglDeleteContext(rc);
|
||||||
|
ReleaseDC(test, dc);
|
||||||
|
DestroyWindow(test);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (togl->MultisampleFlag && !hasMultisampling) {
|
||||||
|
Tcl_SetResult(togl->Interp,
|
||||||
|
TCL_STUPID "multisampling not supported", TCL_STATIC);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (togl->PbufferFlag && !hasPbuffer) {
|
||||||
|
Tcl_SetResult(togl->Interp,
|
||||||
|
TCL_STUPID "pbuffers are not supported", TCL_STATIC);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (choosePixelFormat == NULL) {
|
||||||
|
PIXELFORMATDESCRIPTOR pfd;
|
||||||
|
|
||||||
|
/* Don't have the great wglChoosePixelFormatARB() function, so do it
|
||||||
|
* the old way. */
|
||||||
|
if (togl->MultisampleFlag) {
|
||||||
|
Tcl_SetResult(togl->Interp,
|
||||||
|
TCL_STUPID "multisampling not supported", TCL_STATIC);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(&pfd, 0, sizeof pfd);
|
||||||
|
pfd.nSize = sizeof pfd;
|
||||||
|
pfd.nVersion = 1;
|
||||||
|
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL
|
||||||
|
| PFD_SUPPORT_COMPOSITION;
|
||||||
|
if (togl->DoubleFlag) {
|
||||||
|
pfd.dwFlags |= PFD_DOUBLEBUFFER;
|
||||||
|
}
|
||||||
|
if (togl->Stereo == TOGL_STEREO_NATIVE) {
|
||||||
|
pfd.dwFlags |= PFD_STEREO;
|
||||||
|
}
|
||||||
|
pfd.iPixelType = togl->RgbaFlag ? PFD_TYPE_RGBA : PFD_TYPE_COLORINDEX;
|
||||||
|
pfd.cColorBits = togl->RgbaRed + togl->RgbaGreen + togl->RgbaBlue;
|
||||||
|
/* Alpha bitplanes are not supported in the current generic OpenGL
|
||||||
|
* implementation, but may be supported by specific hardware devices. */
|
||||||
|
pfd.cAlphaBits = togl->AlphaFlag ? togl->AlphaSize : 0;
|
||||||
|
pfd.cAccumBits = togl->AccumFlag ? (togl->AccumRed + togl->AccumGreen +
|
||||||
|
togl->AccumBlue + togl->AccumAlpha) : 0;
|
||||||
|
pfd.cDepthBits = togl->DepthFlag ? togl->DepthSize : 0;
|
||||||
|
pfd.cStencilBits = togl->StencilFlag ? togl->StencilSize : 0;
|
||||||
|
/* Auxiliary buffers are not supported in the current generic OpenGL
|
||||||
|
* implementation, but may be supported by specific hardware devices. */
|
||||||
|
pfd.cAuxBuffers = togl->AuxNumber;
|
||||||
|
pfd.iLayerType = PFD_MAIN_PLANE;
|
||||||
|
|
||||||
|
if ((pixelformat = ChoosePixelFormat(togl->tglGLHdc, &pfd)) == 0) {
|
||||||
|
Tcl_SetResult(togl->Interp,
|
||||||
|
TCL_STUPID "couldn't choose pixel format", TCL_STATIC);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* double check that we got the stereo format we requested */
|
||||||
|
if (togl->Stereo == TOGL_STEREO_NATIVE) {
|
||||||
|
DescribePixelFormat(togl->tglGLHdc, pixelformat, sizeof (pfd),
|
||||||
|
&pfd);
|
||||||
|
if ((pfd.dwFlags & PFD_STEREO) == 0) {
|
||||||
|
Tcl_SetResult(togl->Interp,
|
||||||
|
TCL_STUPID "couldn't choose stereo pixel format",
|
||||||
|
TCL_STATIC);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pixelformat;
|
||||||
|
}
|
||||||
|
// We have the new wglChoosePixelFormat!!
|
||||||
|
if (togl->MultisampleFlag && !hasMultisampling) {
|
||||||
|
Tcl_SetResult(togl->Interp,
|
||||||
|
TCL_STUPID "multisampling not supported", TCL_STATIC);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (togl->PbufferFlag)
|
||||||
|
attribs[na++] = WGL_DRAW_TO_PBUFFER_ARB;
|
||||||
|
else
|
||||||
|
attribs[na++] = WGL_DRAW_TO_WINDOW_ARB;
|
||||||
|
attribs[na++] = GL_TRUE;
|
||||||
|
attribs[na++] = WGL_SUPPORT_OPENGL_ARB;
|
||||||
|
attribs[na++] = GL_TRUE;
|
||||||
|
attribs[na++] = WGL_PIXEL_TYPE_ARB;
|
||||||
|
if (!togl->RgbaFlag) {
|
||||||
|
attribs[na++] = WGL_TYPE_COLORINDEX_ARB;
|
||||||
|
} else {
|
||||||
|
attribs[na++] = WGL_TYPE_RGBA_ARB;
|
||||||
|
attribs[na++] = WGL_RED_BITS_ARB;
|
||||||
|
attribs[na++] = togl->RgbaRed;
|
||||||
|
attribs[na++] = WGL_GREEN_BITS_ARB;
|
||||||
|
attribs[na++] = togl->RgbaGreen;
|
||||||
|
attribs[na++] = WGL_BLUE_BITS_ARB;
|
||||||
|
attribs[na++] = togl->RgbaBlue;
|
||||||
|
if (togl->AlphaFlag) {
|
||||||
|
attribs[na++] = WGL_ALPHA_BITS_ARB;
|
||||||
|
attribs[na++] = togl->AlphaSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (togl->DepthFlag) {
|
||||||
|
attribs[na++] = WGL_DEPTH_BITS_ARB;
|
||||||
|
attribs[na++] = togl->DepthSize;
|
||||||
|
}
|
||||||
|
if (togl->DoubleFlag) {
|
||||||
|
attribs[na++] = WGL_DOUBLE_BUFFER_ARB;
|
||||||
|
attribs[na++] = GL_TRUE;
|
||||||
|
}
|
||||||
|
if (togl->StencilFlag) {
|
||||||
|
attribs[na++] = WGL_STENCIL_BITS_ARB;
|
||||||
|
attribs[na++] = togl->StencilSize;
|
||||||
|
}
|
||||||
|
if (togl->AccumFlag) {
|
||||||
|
attribs[na++] = WGL_ACCUM_RED_BITS_ARB;
|
||||||
|
attribs[na++] = togl->AccumRed;
|
||||||
|
attribs[na++] = WGL_ACCUM_GREEN_BITS_ARB;
|
||||||
|
attribs[na++] = togl->AccumGreen;
|
||||||
|
attribs[na++] = WGL_ACCUM_BLUE_BITS_ARB;
|
||||||
|
attribs[na++] = togl->AccumBlue;
|
||||||
|
if (togl->AlphaFlag) {
|
||||||
|
attribs[na++] = WGL_ACCUM_ALPHA_BITS_ARB;
|
||||||
|
attribs[na++] = togl->AccumAlpha;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (togl->Stereo == TOGL_STEREO_NATIVE) {
|
||||||
|
attribs[na++] = WGL_STEREO_ARB;
|
||||||
|
attribs[na++] = GL_TRUE;
|
||||||
|
}
|
||||||
|
if (togl->MultisampleFlag) {
|
||||||
|
attribs[na++] = WGL_SAMPLE_BUFFERS_ARB;
|
||||||
|
attribs[na++] = 1;
|
||||||
|
attribs[na++] = WGL_SAMPLES_ARB;
|
||||||
|
attribs[na++] = 2;
|
||||||
|
}
|
||||||
|
if (togl->AuxNumber) {
|
||||||
|
attribs[na++] = WGL_AUX_BUFFERS_ARB;
|
||||||
|
attribs[na++] = togl->AuxNumber;
|
||||||
|
}
|
||||||
|
attribs[na++] = 0; // must be last
|
||||||
|
|
||||||
|
if (!choosePixelFormat(togl->tglGLHdc, &attribs[0], NULL, 256, formats,
|
||||||
|
&numFormats) || numFormats == 0) {
|
||||||
|
Tcl_SetResult(togl->Interp,
|
||||||
|
TCL_STUPID "couldn't choose pixel format", TCL_STATIC);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pick best format
|
||||||
|
*/
|
||||||
|
info = (FBInfo *) malloc(numFormats * sizeof (FBInfo));
|
||||||
|
for (i = 0; i != numFormats; ++i) {
|
||||||
|
info[i].pixelFormat = formats[i];
|
||||||
|
getPixelFormatAttribiv(togl->tglGLHdc, formats[i], 0,
|
||||||
|
NUM_FBAttribs, FBAttribs, &info[i].stereo);
|
||||||
|
/* revise attributes so larger is better */
|
||||||
|
if (!togl->DepthFlag)
|
||||||
|
info[i].depth = -info[i].depth;
|
||||||
|
if (!togl->MultisampleFlag)
|
||||||
|
info[i].samples = -info[i].samples;
|
||||||
|
if (togl->Stereo != TOGL_STEREO_NATIVE)
|
||||||
|
info[i].stereo = -info[i].stereo;
|
||||||
|
}
|
||||||
|
qsort(info, numFormats, sizeof info[0], FBInfoCmp);
|
||||||
|
pixelformat = info[0].pixelFormat;
|
||||||
|
/* double check that we got the stereo format we requested */
|
||||||
|
if (togl->Stereo == TOGL_STEREO_NATIVE && !info[0].stereo) {
|
||||||
|
Tcl_SetResult(togl->Interp,
|
||||||
|
TCL_STUPID "couldn't choose stereo pixel format", TCL_STATIC);
|
||||||
|
free(info);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
free(info);
|
||||||
|
return pixelformat;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
togl_describePixelFormat(Togl *togl)
|
||||||
|
{
|
||||||
|
if (getPixelFormatAttribiv == NULL) {
|
||||||
|
PIXELFORMATDESCRIPTOR pfd;
|
||||||
|
|
||||||
|
DescribePixelFormat(togl->tglGLHdc, (int) togl->PixelFormat,
|
||||||
|
sizeof (pfd), &pfd);
|
||||||
|
/* fill in flags normally passed in that affect behavior */
|
||||||
|
togl->RgbaFlag = pfd.iPixelType == PFD_TYPE_RGBA;
|
||||||
|
togl->DoubleFlag = (pfd.dwFlags & PFD_DOUBLEBUFFER) != 0;
|
||||||
|
togl->DepthFlag = (pfd.cDepthBits != 0);
|
||||||
|
togl->AccumFlag = (pfd.cAccumBits != 0);
|
||||||
|
togl->AlphaFlag = (pfd.cAlphaBits != 0);
|
||||||
|
togl->StencilFlag = (pfd.cStencilBits != 0);
|
||||||
|
if ((pfd.dwFlags & PFD_STEREO) != 0)
|
||||||
|
togl->Stereo = TOGL_STEREO_NATIVE;
|
||||||
|
else
|
||||||
|
togl->Stereo = TOGL_STEREO_NONE;
|
||||||
|
} else {
|
||||||
|
static int attribs[] = {
|
||||||
|
WGL_PIXEL_TYPE_ARB,
|
||||||
|
WGL_DOUBLE_BUFFER_ARB,
|
||||||
|
WGL_DEPTH_BITS_ARB,
|
||||||
|
WGL_ACCUM_RED_BITS_ARB,
|
||||||
|
WGL_ALPHA_BITS_ARB,
|
||||||
|
WGL_STENCIL_BITS_ARB,
|
||||||
|
WGL_STEREO_ARB,
|
||||||
|
WGL_SAMPLES_ARB
|
||||||
|
};
|
||||||
|
#define NUM_ATTRIBS (sizeof attribs / sizeof attribs[0])
|
||||||
|
int info[NUM_ATTRIBS];
|
||||||
|
|
||||||
|
getPixelFormatAttribiv(togl->tglGLHdc, (int) togl->PixelFormat, 0,
|
||||||
|
NUM_ATTRIBS, attribs, info);
|
||||||
|
#undef NUM_ATTRIBS
|
||||||
|
togl->RgbaFlag = info[0];
|
||||||
|
togl->DoubleFlag = info[1];
|
||||||
|
togl->DepthFlag = (info[2] != 0);
|
||||||
|
togl->AccumFlag = (info[3] != 0);
|
||||||
|
togl->AlphaFlag = (info[4] != 0);
|
||||||
|
togl->StencilFlag = (info[5] != 0);
|
||||||
|
togl->Stereo = info[6] ? TOGL_STEREO_NATIVE : TOGL_STEREO_NONE;
|
||||||
|
togl->MultisampleFlag = (info[7] != 0);
|
||||||
|
}
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HPBUFFERARB
|
||||||
|
togl_createPbuffer(Togl *togl)
|
||||||
|
{
|
||||||
|
int attribs[32];
|
||||||
|
int na = 0;
|
||||||
|
HPBUFFERARB pbuf;
|
||||||
|
|
||||||
|
if (togl->LargestPbufferFlag) {
|
||||||
|
attribs[na++] = WGL_PBUFFER_LARGEST_ARB;
|
||||||
|
attribs[na++] = 1;
|
||||||
|
}
|
||||||
|
attribs[na] = 0;
|
||||||
|
pbuf = createPbuffer(togl->tglGLHdc, (int) togl->PixelFormat, togl->Width,
|
||||||
|
togl->Height, attribs);
|
||||||
|
if (pbuf && togl->LargestPbufferFlag) {
|
||||||
|
queryPbuffer(pbuf, WGL_PBUFFER_WIDTH_ARB, &togl->Width);
|
||||||
|
queryPbuffer(pbuf, WGL_PBUFFER_HEIGHT_ARB, &togl->Height);
|
||||||
|
}
|
||||||
|
return pbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
togl_destroyPbuffer(Togl *togl)
|
||||||
|
{
|
||||||
|
destroyPbuffer(togl->pbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// From nvidia.com
|
||||||
|
|
||||||
|
Multisampling requires WGL_ARB_extension_string and WGL_ARB_pixel_format
|
||||||
|
wglGetProcAddress("wglGetExtensionsStringARB")
|
||||||
|
// From msdn.microsoft.com, various ways to enumerate PixelFormats
|
||||||
|
void CPixForm::OnClickedLastPfd()
|
||||||
|
{
|
||||||
|
COpenGL gl;
|
||||||
|
PIXELFORMATDESCRIPTOR pfd;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get the hwnd of the view window.
|
||||||
|
//
|
||||||
|
HWND hwndview = GetViewHwnd();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get a DC associated with the view window.
|
||||||
|
//
|
||||||
|
HDC dc =::GetDC(hwndview);
|
||||||
|
int nID = (m_nNextID > 1) ? m_nNextID-- : 1;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get a description of the pixel format. If it is valid, then go and
|
||||||
|
// update the controls in the dialog box, otherwise do nothing.
|
||||||
|
//
|
||||||
|
if (gl.DescribePixelFormat(dc, nID, sizeof (PIXELFORMATDESCRIPTOR), &pfd))
|
||||||
|
UpdateDlg(&pfd);
|
||||||
|
//
|
||||||
|
// Release the DC.
|
||||||
|
//
|
||||||
|
::ReleaseDC(hwndview, dc);
|
||||||
|
}
|
||||||
|
|
||||||
|
----------------------
|
||||||
|
// local variables
|
||||||
|
int iMax;
|
||||||
|
PIXELFORMATDESCRIPTOR pfd;
|
||||||
|
int iPixelFormat;
|
||||||
|
|
||||||
|
// initialize a pixel format index variable
|
||||||
|
iPixelFormat = 1;
|
||||||
|
|
||||||
|
// keep obtaining and examining pixel format data...
|
||||||
|
do {
|
||||||
|
// try to obtain some pixel format data
|
||||||
|
iMax = DescribePixelFormat(dc, iPixelFormat, sizeof (pfd), &pfd);
|
||||||
|
|
||||||
|
// if there was some problem with that...
|
||||||
|
if (iMax == 0)
|
||||||
|
// return indicating failure
|
||||||
|
return (FALSE);
|
||||||
|
|
||||||
|
// we have successfully obtained pixel format data
|
||||||
|
|
||||||
|
// let's examine the pixel format data...
|
||||||
|
myPixelFormatExaminer(&pfd);
|
||||||
|
}
|
||||||
|
// ...until we've looked at all the device context's pixel formats
|
||||||
|
while (++iPixelFormat <= iMax);
|
||||||
|
#endif
|
7
ng/Togl2.1/togl_ws.h.in
Normal file
7
ng/Togl2.1/togl_ws.h.in
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#ifndef TOGL_WS_H
|
||||||
|
# define TOGL_WS_H
|
||||||
|
|
||||||
|
/* define windowing system togl is compiled with */
|
||||||
|
# define @TOGL_WINDOWINGSYSTEM@
|
||||||
|
|
||||||
|
#endif
|
81
ng/Togl2.1/toglpy.h
Normal file
81
ng/Togl2.1/toglpy.h
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* getToglFromWidget:
|
||||||
|
*
|
||||||
|
* Given a Python widget, get the corresponding Togl pointer. <Python.h>
|
||||||
|
* and <togl.h> should be included before this. If included into a C file,
|
||||||
|
* there should be a static keyword just before the include.
|
||||||
|
*
|
||||||
|
* There should be one copy of getToglFromWidget per-shared libary so that
|
||||||
|
* the library's Tcl/Tk/Togl stub pointers are properly initialized.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 Greg Couch
|
||||||
|
* See the LICENSE file for copyright details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Togl *
|
||||||
|
getToglFromWidget(PyObject *widget)
|
||||||
|
{
|
||||||
|
PyObject *cmdNameObj, *tk, *interpAddr;
|
||||||
|
const char *cmdName;
|
||||||
|
Tcl_Interp *interp;
|
||||||
|
Togl *curTogl;
|
||||||
|
|
||||||
|
#ifdef USE_TOGL_STUBS
|
||||||
|
static int didOnce = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Python: cmdName = widget._w */
|
||||||
|
/* Python: interpAddr = widget.tk.interpaddr() */
|
||||||
|
cmdNameObj = PyObject_GetAttrString(widget, "_w");
|
||||||
|
tk = PyObject_GetAttrString(widget, "tk");
|
||||||
|
if (cmdNameObj == NULL || !PyString_Check(cmdNameObj) || tk == NULL) {
|
||||||
|
Py_XDECREF(cmdNameObj);
|
||||||
|
Py_XDECREF(tk);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
throw std::invalid_argument("not a Tk widget");
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
interpAddr = PyEval_CallMethod(tk, "interpaddr", "()");
|
||||||
|
if (interpAddr == NULL || !PyInt_Check(interpAddr)) {
|
||||||
|
Py_DECREF(cmdNameObj);
|
||||||
|
Py_DECREF(tk);
|
||||||
|
Py_XDECREF(interpAddr);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
throw std::invalid_argument("not a Tk widget");
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdName = PyString_AsString(cmdNameObj);
|
||||||
|
interp = (Tcl_Interp *) PyInt_AsLong(interpAddr);
|
||||||
|
|
||||||
|
#ifdef USE_TOGL_STUBS
|
||||||
|
if (!didOnce) {
|
||||||
|
/* make sure stubs are initialized before calling a Togl function. */
|
||||||
|
if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL
|
||||||
|
|| Tk_InitStubs(interp, TK_VERSION, 0) == NULL
|
||||||
|
|| Togl_InitStubs(interp, TOGL_VERSION, 0) == NULL)
|
||||||
|
# ifdef __cplusplus
|
||||||
|
throw std::runtime_error("unable to initialize Togl");
|
||||||
|
# else
|
||||||
|
return NULL;
|
||||||
|
# endif
|
||||||
|
didOnce = 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (Togl_GetToglFromName(interp, cmdName, &curTogl) != TCL_OK)
|
||||||
|
curTogl = NULL;
|
||||||
|
Py_DECREF(cmdNameObj);
|
||||||
|
Py_DECREF(tk);
|
||||||
|
Py_DECREF(interpAddr);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
if (curTogl == NULL)
|
||||||
|
throw std::invalid_argument("not a Togl widget");
|
||||||
|
#endif
|
||||||
|
return curTogl;
|
||||||
|
}
|
BIN
ng/Togl2.1/tree2.rgba
Normal file
BIN
ng/Togl2.1/tree2.rgba
Normal file
Binary file not shown.
674
ng/dialog.tcl
674
ng/dialog.tcl
@ -5,30 +5,43 @@ proc meshingoptionsdialog { } {
|
|||||||
if {[winfo exists .options_dlg] == 1} {
|
if {[winfo exists .options_dlg] == 1} {
|
||||||
wm withdraw $w
|
wm withdraw $w
|
||||||
wm deiconify $w
|
wm deiconify $w
|
||||||
focus $w
|
focus $w
|
||||||
|
|
||||||
} {
|
} {
|
||||||
|
|
||||||
toplevel $w
|
toplevel $w
|
||||||
|
wm resizable $w 0 0
|
||||||
|
|
||||||
# global options.meshsize
|
# global options.meshsize
|
||||||
|
|
||||||
tixNoteBook $w.nb -ipadx 6 -ipady 6
|
pack [ttk::notebook $w.nb] -fill both -side top
|
||||||
|
$w.nb add [ttk::frame $w.nb.general] -text "General" -underline 0
|
||||||
$w.nb add general -label "General" -underline 0
|
$w.nb add [ttk::frame $w.nb.meshsize] -text "Mesh Size" -underline 0
|
||||||
$w.nb add meshsize -label "Mesh Size" -underline 0
|
$w.nb add [ttk::frame $w.nb.chartopt] -text "STL Charts" -underline 0
|
||||||
$w.nb add chartopt -label "STL Charts" -underline 0
|
$w.nb add [ttk::frame $w.nb.optimizer] -text "Optimizer" -underline 0
|
||||||
$w.nb add optimizer -label "Optimizer" -underline 0
|
# $w.nb add [ttk::frame $w.nb.insider] -text "Insider" -underline 0
|
||||||
$w.nb add insider -label "Insider" -underline 0
|
$w.nb add [ttk::frame $w.nb.debug] -text "Debug" -underline 0
|
||||||
$w.nb add debug -label "Debug" -underline 0
|
|
||||||
|
# tixNoteBook $w.nbold -ipadx 6 -ipady 6
|
||||||
|
# $w.nbold add general -label "General" -underline 0
|
||||||
pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top
|
# $w.nbold add meshsize -label "Mesh Size" -underline 0
|
||||||
|
# $w.nbold add chartopt -label "STL Charts" -underline 0
|
||||||
|
# $w.nbold add optimizer -label "Optimizer" -underline 0
|
||||||
|
# $w.nbold add insider -label "Insider" -underline 0
|
||||||
|
# $w.nbold add debug -label "Debug" -underline 0
|
||||||
|
# pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top
|
||||||
|
|
||||||
|
|
||||||
|
# ############################################################
|
||||||
# General meshing options
|
# General meshing options
|
||||||
|
# ############################################################
|
||||||
|
|
||||||
|
set f $w.nb.general
|
||||||
|
|
||||||
set f [$w.nb subwidget general]
|
ttk::frame $f.f2
|
||||||
|
pack $f.f2 -pady 10
|
||||||
|
set f $f.f2
|
||||||
|
|
||||||
set finevals { 1 2 3 4 5 6 }
|
set finevals { 1 2 3 4 5 6 }
|
||||||
set finelabs(1) "very coarse"
|
set finelabs(1) "very coarse"
|
||||||
set finelabs(2) "coarse"
|
set finelabs(2) "coarse"
|
||||||
@ -44,7 +57,6 @@ proc meshingoptionsdialog { } {
|
|||||||
menubutton.width 15
|
menubutton.width 15
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
foreach finev $finevals {
|
foreach finev $finevals {
|
||||||
$f.fine add command $finev -label $finelabs($finev)
|
$f.fine add command $finev -label $finelabs($finev)
|
||||||
}
|
}
|
||||||
@ -52,10 +64,23 @@ proc meshingoptionsdialog { } {
|
|||||||
$f.fine config -command { setgranularity }
|
$f.fine config -command { setgranularity }
|
||||||
global meshoptions.fineness
|
global meshoptions.fineness
|
||||||
# setgranularity ${meshoptions.fineness}
|
# setgranularity ${meshoptions.fineness}
|
||||||
pack $f.fine
|
# pack $f.fine
|
||||||
|
|
||||||
|
global meshoptions.fineness
|
||||||
|
ttk::frame $f.fine2
|
||||||
|
ttk::label $f.fine2.l -text "Mesh granularity: "
|
||||||
|
ttk::menubutton $f.fine2.c -menu $f.fine2.m -text "coarse" -width 14
|
||||||
|
|
||||||
|
menu $f.fine2.m -tearoff 0
|
||||||
|
foreach finev { 1 2 3 4 5 6 } {
|
||||||
|
$f.fine2.m add command -label $finelabs($finev) \
|
||||||
|
-command "set meshoptions.fineness $finev ; setgranularity $finev; $f.fine2.c configure -text \"$finelabs($finev)\""
|
||||||
|
}
|
||||||
|
$f.fine2.m invoke $finelabs(${meshoptions.fineness})
|
||||||
|
|
||||||
|
|
||||||
|
pack $f.fine2 -fill x
|
||||||
|
pack $f.fine2.c $f.fine2.l -side right
|
||||||
|
|
||||||
|
|
||||||
set mgsteps { ag me ms os mv ov }
|
set mgsteps { ag me ms os mv ov }
|
||||||
@ -66,30 +91,59 @@ proc meshingoptionsdialog { } {
|
|||||||
set mgsteplabel(mv) "Mesh Volume"
|
set mgsteplabel(mv) "Mesh Volume"
|
||||||
set mgsteplabel(ov) "Optimize Volume"
|
set mgsteplabel(ov) "Optimize Volume"
|
||||||
|
|
||||||
|
global meshoptions.firststep
|
||||||
tixOptionMenu $f.first -label "First Step : " \
|
ttk::frame $f.first2
|
||||||
-options {
|
ttk::label $f.first2.l -text "First Step: "
|
||||||
label.width 19
|
# ttk::menubutton $f.first2.c -menu $f.first2.m -text "Analyze Geometry" -width 12
|
||||||
label.anchor e
|
ttk::menubutton $f.first2.c -menu $f.first2.m -width 14
|
||||||
menubutton.width 15
|
|
||||||
}
|
menu $f.first2.m -tearoff 0
|
||||||
|
foreach i $mgsteps {
|
||||||
tixOptionMenu $f.last -label "Last Step : " \
|
$f.first2.m add command -label $mgsteplabel($i) -command "set meshoptions.firststep $i ; $f.first2.c configure -text \"$mgsteplabel($i)\""
|
||||||
-options {
|
|
||||||
label.width 19
|
|
||||||
label.anchor e
|
|
||||||
menubutton.width 15
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach step $mgsteps {
|
|
||||||
$f.first add command $step -label $mgsteplabel($step)
|
|
||||||
$f.last add command $step -label $mgsteplabel($step)
|
|
||||||
}
|
}
|
||||||
|
$f.first2.m invoke $mgsteplabel(${meshoptions.firststep})
|
||||||
|
pack $f.first2 -fill x
|
||||||
|
pack $f.first2.c $f.first2.l -side right
|
||||||
|
|
||||||
$f.first config -variable meshoptions.firststep
|
global meshoptions.laststep
|
||||||
$f.last config -variable meshoptions.laststep
|
ttk::frame $f.last2
|
||||||
|
ttk::label $f.last2.l -text "Last Step: "
|
||||||
|
ttk::menubutton $f.last2.c -menu $f.last2.m -width 14
|
||||||
|
|
||||||
pack $f.first $f.last
|
menu $f.last2.m -tearoff 0
|
||||||
|
|
||||||
|
foreach i $mgsteps {
|
||||||
|
$f.last2.m add command -label $mgsteplabel($i) -command "set meshoptions.laststep $i ; $f.last2.c configure -text \"$mgsteplabel($i)\""
|
||||||
|
}
|
||||||
|
$f.last2.m invoke $mgsteplabel(${meshoptions.laststep})
|
||||||
|
pack $f.last2 -fill x
|
||||||
|
pack $f.last2.c $f.last2.l -side right
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# tixOptionMenu $f.first -label "First Step : " \
|
||||||
|
# -options {
|
||||||
|
# label.width 19
|
||||||
|
# label.anchor e
|
||||||
|
# menubutton.width 15
|
||||||
|
# }
|
||||||
|
|
||||||
|
# tixOptionMenu $f.last -label "Last Step : " \
|
||||||
|
# -options {
|
||||||
|
# label.width 19
|
||||||
|
# label.anchor e
|
||||||
|
# menubutton.width 15
|
||||||
|
# }
|
||||||
|
|
||||||
|
# foreach step $mgsteps {
|
||||||
|
# $f.first add command $step -label $mgsteplabel($step)
|
||||||
|
# $f.last add command $step -label $mgsteplabel($step)
|
||||||
|
# }
|
||||||
|
|
||||||
|
# $f.first config -variable meshoptions.firststep
|
||||||
|
# $f.last config -variable meshoptions.laststep
|
||||||
|
|
||||||
|
# pack $f.first $f.last
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -109,107 +163,157 @@ proc meshingoptionsdialog { } {
|
|||||||
menubutton.width 15
|
menubutton.width 15
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach step {0 1 2 3 4 5 } {
|
foreach step {0 1 2 3 4 5 } {
|
||||||
$f.msg add command $step -label $msg($step)
|
$f.msg add command $step -label $msg($step)
|
||||||
}
|
}
|
||||||
|
|
||||||
$f.msg config -variable options.printmsg
|
$f.msg config -variable options.printmsg
|
||||||
pack $f.msg
|
# pack $f.msg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
global options.printmsg
|
||||||
|
ttk::frame $f.msg2
|
||||||
|
ttk::label $f.msg2.l -text "Print Messages: "
|
||||||
|
menu $f.msg2.m -tearoff 0
|
||||||
|
ttk::menubutton $f.msg2.c -menu $f.msg2.m -width 14
|
||||||
|
foreach step {0 1 2 3 4 5 } {
|
||||||
|
$f.msg2.m add command -label $msg($step) -command "set options.printmsg $step ; $f.msg2.c configure -text $msg($step)"
|
||||||
|
# if { ${options.printmsg} == $step } { $f.msg2.c configure -text $msg($step) }
|
||||||
|
}
|
||||||
|
$f.msg2.m invoke ${options.printmsg}
|
||||||
|
pack $f.msg2 -fill x
|
||||||
|
pack $f.msg2.c $f.msg2.l -side right
|
||||||
|
|
||||||
|
|
||||||
|
set f $w.nb.general
|
||||||
|
|
||||||
|
ttk::frame $f.bts
|
||||||
|
pack $f.bts -side top -pady 10
|
||||||
|
|
||||||
|
ttk::checkbutton $f.bts.parthread -text "Parallel meshing thread" \
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
checkbutton $f.parthread -text "Parallel meshing thread" \
|
|
||||||
-variable options.parthread
|
-variable options.parthread
|
||||||
checkbutton $f.second -text "Second order elements" \
|
ttk::checkbutton $f.bts.second -text "Second order elements" \
|
||||||
-variable options.secondorder
|
-variable options.secondorder
|
||||||
checkbutton $f.quad -text "Quad dominated" \
|
ttk::checkbutton $f.bts.quad -text "Quad dominated" \
|
||||||
-variable options.quad -command {
|
-variable options.quad -command {
|
||||||
if { ${options.quad} } {
|
if { ${options.quad} } {
|
||||||
set meshoptions.laststep os
|
set meshoptions.laststep os
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkbutton $f.invtets -text "Invert volume elements" \
|
ttk::checkbutton $f.bts.invtets -text "Invert volume elements" \
|
||||||
-variable options.inverttets
|
-variable options.inverttets
|
||||||
checkbutton $f.invtrigs -text "Invert surface elements" \
|
ttk::checkbutton $f.bts.invtrigs -text "Invert surface elements" \
|
||||||
-variable options.inverttrigs
|
-variable options.inverttrigs
|
||||||
checkbutton $f.azref -text "Automatic Z-refinement" \
|
ttk::checkbutton $f.bts.azref -text "Automatic Z-refinement" \
|
||||||
-variable options.autozrefine
|
-variable options.autozrefine
|
||||||
|
|
||||||
pack $f.parthread $f.second $f.quad $f.invtets $f.invtrigs $f.azref
|
pack $f.bts.parthread $f.bts.second $f.bts.quad $f.bts.invtets $f.bts.invtrigs $f.bts.azref -fill x
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# tixControl $f.elementorder -label "Element order: " -integer true \
|
||||||
|
# -variable options.elementorder -min 1 -max 20 \
|
||||||
|
# -options {
|
||||||
|
# entry.width 2
|
||||||
|
# label.width 20
|
||||||
|
# label.anchor e
|
||||||
|
# }
|
||||||
|
# pack $f.elementorder
|
||||||
|
|
||||||
tixControl $f.elementorder -label "Element order: " -integer true \
|
ttk::frame $f.sbox
|
||||||
-variable options.elementorder -min 1 -max 20 \
|
pack $f.sbox
|
||||||
-options {
|
ttk::label $f.sbox.l -text "Element order: "
|
||||||
entry.width 2
|
ttk::spinbox $f.sbox.elementorder2 -from 1 -to 20 -textvariable options.elementorder -width 2
|
||||||
label.width 20
|
pack $f.sbox.l $f.sbox.elementorder2 -side left
|
||||||
label.anchor e
|
|
||||||
}
|
|
||||||
|
|
||||||
pack $f.elementorder
|
|
||||||
|
|
||||||
|
|
||||||
# tixControl $f.memory -label "Large Memory \[MB\]: " -integer true \
|
# ############################################################
|
||||||
\# -variable options.memory -min 0 -max 2000 \
|
# Mesh - Size options
|
||||||
\# -options {
|
# ############################################################
|
||||||
# entry.width 5
|
|
||||||
# label.width 20
|
|
||||||
# label.anchor e
|
|
||||||
# }
|
|
||||||
|
|
||||||
# global userlevel
|
set f $w.nb.meshsize
|
||||||
# if { $userlevel >= 3} { pack $f.memory }
|
|
||||||
|
|
||||||
|
ttk::frame $f.f2
|
||||||
|
pack $f.f2 -pady 10
|
||||||
|
|
||||||
# Mesh - Size options
|
# # ttk::style configure Tframe -background red
|
||||||
set f [$w.nb subwidget meshsize]
|
# puts "********************"
|
||||||
|
# puts "found these themes:"
|
||||||
|
# puts [ttk::themes]
|
||||||
|
# ttk::setTheme classic
|
||||||
|
# ttk::setTheme aqua
|
||||||
|
# puts "style Tframe foreground = "
|
||||||
|
# puts [ttk::style lookup Tframe -foreground]
|
||||||
|
# puts "f2 style:"
|
||||||
|
# puts [$f.f2 cget -style]
|
||||||
|
# puts [winfo class $f.f2]
|
||||||
|
# puts "style element names gives:"
|
||||||
|
# puts [ttk::style element names]
|
||||||
|
|
||||||
tixControl $f.meshsize -label "max mesh-size: " -integer false \
|
|
||||||
-variable options.meshsize -min 1e-9 -max 1e6 \
|
set f $f.f2
|
||||||
-options {
|
|
||||||
entry.width 6
|
ttk::frame $f.meshsize
|
||||||
label.width 25
|
ttk::label $f.meshsize.l -text "max mesh-size"
|
||||||
label.anchor e
|
ttk::spinbox $f.meshsize.s -from 1e-9 -to 1e9 -textvariable options.meshsize -width 5
|
||||||
}
|
pack $f.meshsize -fill x
|
||||||
|
pack $f.meshsize.s $f.meshsize.l -side right
|
||||||
|
|
||||||
tixControl $f.minmeshsize -label "min mesh-size: " -integer false \
|
ttk::frame $f.minmeshsize
|
||||||
-variable options.minmeshsize -min 0 -max 1e6 \
|
ttk::label $f.minmeshsize.l -text "min mesh-size"
|
||||||
-options {
|
ttk::spinbox $f.minmeshsize.s -from 0 -to 1e9 -textvariable options.minmeshsize -width 5
|
||||||
entry.width 6
|
pack $f.minmeshsize -fill x
|
||||||
label.width 25
|
pack $f.minmeshsize.s $f.minmeshsize.l -side right
|
||||||
label.anchor e
|
|
||||||
}
|
|
||||||
|
|
||||||
tixControl $f.grading -label "mesh-size grading: " -integer false \
|
ttk::frame $f.grading
|
||||||
-variable options.grading -min 0.1 -max 1 -step 0.1 \
|
ttk::label $f.grading.l -text "mesh-size grading"
|
||||||
-options {
|
ttk::spinbox $f.grading.s -from 0.1 -to 1.0 -textvariable options.grading -width 5 -increment 0.1
|
||||||
entry.width 6
|
pack $f.grading -fill x
|
||||||
label.width 25
|
pack $f.grading.s $f.grading.l -side right
|
||||||
label.anchor e
|
|
||||||
}
|
|
||||||
|
# tixControl $f.meshsize -label "max mesh-size: " -integer false \
|
||||||
|
# -variable options.meshsize -min 1e-9 -max 1e6 \
|
||||||
|
# -options {
|
||||||
|
# entry.width 6
|
||||||
|
# label.width 25
|
||||||
|
# label.anchor e
|
||||||
|
# }
|
||||||
|
|
||||||
|
# tixControl $f.minmeshsize -label "min mesh-size: " -integer false \
|
||||||
|
# -variable options.minmeshsize -min 0 -max 1e6 \
|
||||||
|
# -options {
|
||||||
|
# entry.width 6
|
||||||
|
# label.width 25
|
||||||
|
# label.anchor e
|
||||||
|
# }
|
||||||
|
|
||||||
|
# tixControl $f.grading -label "mesh-size grading: " -integer false \
|
||||||
|
# -variable options.grading -min 0.1 -max 1 -step 0.1 \
|
||||||
|
# -options {
|
||||||
|
# entry.width 6
|
||||||
|
# label.width 25
|
||||||
|
# label.anchor e
|
||||||
|
# }
|
||||||
|
|
||||||
pack $f.meshsize $f.minmeshsize $f.grading
|
# pack $f.meshsize $f.minmeshsize $f.grading
|
||||||
|
|
||||||
|
set f $w.nb.meshsize
|
||||||
|
|
||||||
|
ttk::labelframe $f.msf -text "mesh-size file:"
|
||||||
frame $f.msf
|
|
||||||
pack $f.msf
|
pack $f.msf
|
||||||
|
|
||||||
tixLabelEntry $f.msf.ent -label "mesh-size file: " \
|
# tixLabelEntry $f.msf.ent -label "mesh-size file: " \
|
||||||
-labelside top \
|
# -labelside top \
|
||||||
-options {
|
# -options {
|
||||||
entry.textVariable options.meshsizefilename
|
# entry.textVariable options.meshsizefilename
|
||||||
entry.width 35
|
# entry.width 35
|
||||||
label.width 25
|
# label.width 25
|
||||||
label.anchor w
|
# label.anchor w
|
||||||
}
|
# }
|
||||||
button $f.msf.btn -text "Browse" -command {
|
|
||||||
|
ttk::entry $f.msf.ent -textvariable options.meshsizefilename -width 30
|
||||||
|
ttk::button $f.msf.btn -text "Browse" -command {
|
||||||
global options.meshsizefilename
|
global options.meshsizefilename
|
||||||
set types {
|
set types {
|
||||||
{"Meshsize file" {.msz} } }
|
{"Meshsize file" {.msz} } }
|
||||||
@ -224,86 +328,93 @@ proc meshingoptionsdialog { } {
|
|||||||
|
|
||||||
#csg-meshsize options
|
#csg-meshsize options
|
||||||
|
|
||||||
frame $f.csg -relief groove -borderwidth 3
|
ttk::labelframe $f.csg -relief groove -borderwidth 3 -text "CSG mesh-size"
|
||||||
pack $f.csg -fill x
|
pack $f.csg -fill x
|
||||||
|
|
||||||
|
ttk::frame $f.csg.curv
|
||||||
frame $f.csg.curv
|
pack $f.csg.curv -fill x
|
||||||
pack $f.csg.curv -anchor w
|
ttk::scale $f.csg.curv.sc -orient horizontal -length 150 -from 0.2 -to 5 \
|
||||||
|
-variable options.curvaturesafety
|
||||||
scale $f.csg.curv.sc -orient horizontal -length 200 -from 0.2 -to 5 \
|
# -resolution 0.1
|
||||||
-resolution 0.1 -variable options.curvaturesafety
|
ttk::entry $f.csg.curv.e -textvariable options.curvaturesafety -width 3
|
||||||
label $f.csg.curv.la -text "Elements per curvature radius"
|
ttk::label $f.csg.curv.la -text "Elements per curvature radius"
|
||||||
pack $f.csg.curv.sc $f.csg.curv.la -side left
|
pack $f.csg.curv.sc $f.csg.curv.e $f.csg.curv.la -side left -padx 4
|
||||||
|
|
||||||
frame $f.csg.elen
|
ttk::frame $f.csg.elen
|
||||||
pack $f.csg.elen -anchor w
|
pack $f.csg.elen -fill x
|
||||||
scale $f.csg.elen.sc -orient horizontal -length 200 -from 0.2 -to 5 \
|
ttk::scale $f.csg.elen.sc -orient horizontal -length 150 -from 0.2 -to 5 \
|
||||||
-resolution 0.1 -variable options.segmentsperedge
|
-variable options.segmentsperedge
|
||||||
label $f.csg.elen.la -text "Elements per edge"
|
# -resolution 0.1
|
||||||
pack $f.csg.elen.sc $f.csg.elen.la -side left
|
ttk::entry $f.csg.elen.e -textvariable options.segmentsperedge -width 3
|
||||||
|
ttk::label $f.csg.elen.la -text "Elements per edge"
|
||||||
|
pack $f.csg.elen.sc $f.csg.elen.e $f.csg.elen.la -side left -padx 4
|
||||||
|
|
||||||
|
|
||||||
#stl-meshsize options
|
#stl-meshsize options
|
||||||
|
ttk::labelframe $f.stl -relief groove -borderwidth 3 -text "STL mesh-size"
|
||||||
|
pack $f.stl
|
||||||
|
|
||||||
frame $f.stl -relief groove -borderwidth 3
|
ttk::frame $f.stl.r2
|
||||||
pack $f.stl -fill x
|
pack $f.stl.r2 -fill x
|
||||||
|
ttk::scale $f.stl.r2.sc -orient horizontal -length 150 -from 0.2 -to 5 \
|
||||||
frame $f.stl.r2
|
-variable stloptions.resthchartdistfac
|
||||||
pack $f.stl.r2 -anchor w
|
ttk::entry $f.stl.r2.e -textvariable stloptions.resthchartdistfac -width 3
|
||||||
scale $f.stl.r2.sc -orient horizontal -length 200 -from 0.2 -to 5 \
|
ttk::checkbutton $f.stl.r2.bu -text "STL - chart distance" \
|
||||||
-resolution 0.1 -variable stloptions.resthchartdistfac
|
|
||||||
checkbutton $f.stl.r2.bu -text "STL - chart distance" \
|
|
||||||
-variable stloptions.resthchartdistenable
|
-variable stloptions.resthchartdistenable
|
||||||
pack $f.stl.r2.sc $f.stl.r2.bu -side left
|
pack $f.stl.r2.sc $f.stl.r2.e $f.stl.r2.bu -side left -padx 4
|
||||||
|
|
||||||
frame $f.stl.r6
|
ttk::frame $f.stl.r6
|
||||||
pack $f.stl.r6 -anchor w
|
pack $f.stl.r6 -anchor w
|
||||||
scale $f.stl.r6.sc -orient horizontal -length 200 -from 0.2 -to 5 \
|
ttk::scale $f.stl.r6.sc -orient horizontal -length 150 -from 0.2 -to 5 \
|
||||||
-resolution 0.1 -variable stloptions.resthlinelengthfac
|
-variable stloptions.resthlinelengthfac
|
||||||
checkbutton $f.stl.r6.bu -text "STL - line length" \
|
ttk::entry $f.stl.r6.e -textvariable stloptions.resthlinelengthfac -width 3
|
||||||
|
ttk::checkbutton $f.stl.r6.bu -text "STL - line length" \
|
||||||
-variable stloptions.resthlinelengthenable
|
-variable stloptions.resthlinelengthenable
|
||||||
pack $f.stl.r6.sc $f.stl.r6.bu -side left
|
pack $f.stl.r6.sc $f.stl.r6.e $f.stl.r6.bu -side left -padx 4
|
||||||
|
|
||||||
frame $f.stl.r3
|
ttk::frame $f.stl.r3
|
||||||
pack $f.stl.r3 -anchor w
|
pack $f.stl.r3 -anchor w
|
||||||
scale $f.stl.r3.sc -orient horizontal -length 200 -from 0.2 -to 8 \
|
ttk::scale $f.stl.r3.sc -orient horizontal -length 150 -from 0.2 -to 8 \
|
||||||
-resolution 0.1 -variable stloptions.resthcloseedgefac
|
-variable stloptions.resthcloseedgefac
|
||||||
checkbutton $f.stl.r3.bu -text "STL/IGES/STEP - close edges" \
|
ttk::entry $f.stl.r3.e -textvariable stloptions.resthcloseedgefac -width 3
|
||||||
|
ttk::checkbutton $f.stl.r3.bu -text "STL/IGES/STEP - close edges" \
|
||||||
-variable stloptions.resthcloseedgeenable
|
-variable stloptions.resthcloseedgeenable
|
||||||
|
|
||||||
pack $f.stl.r3.sc $f.stl.r3.bu -side left
|
pack $f.stl.r3.sc $f.stl.r3.e $f.stl.r3.bu -side left -padx 4
|
||||||
|
|
||||||
frame $f.stl.r1
|
ttk::frame $f.stl.r1
|
||||||
pack $f.stl.r1 -anchor w
|
pack $f.stl.r1 -anchor w
|
||||||
scale $f.stl.r1.sc -orient horizontal -length 200 -from 0.2 -to 5 \
|
ttk::scale $f.stl.r1.sc -orient horizontal -length 150 -from 0.2 -to 5 \
|
||||||
-resolution 0.1 -variable stloptions.resthsurfcurvfac
|
-variable stloptions.resthsurfcurvfac
|
||||||
checkbutton $f.stl.r1.bu -text "STL - surface curvature" \
|
ttk::entry $f.stl.r1.e -textvariable stloptions.resthsurfcurvfac -width 3
|
||||||
|
ttk::checkbutton $f.stl.r1.bu -text "STL - surface curvature" \
|
||||||
-variable stloptions.resthsurfcurvenable
|
-variable stloptions.resthsurfcurvenable
|
||||||
pack $f.stl.r1.sc $f.stl.r1.bu -side left
|
pack $f.stl.r1.sc $f.stl.r1.e $f.stl.r1.bu -side left -padx 4
|
||||||
|
|
||||||
frame $f.stl.r3b
|
ttk::frame $f.stl.r3b
|
||||||
pack $f.stl.r3b -anchor w
|
pack $f.stl.r3b -anchor w
|
||||||
scale $f.stl.r3b.sc -orient horizontal -length 200 -from 0.2 -to 5 \
|
ttk::scale $f.stl.r3b.sc -orient horizontal -length 150 -from 0.2 -to 5 \
|
||||||
-resolution 0.1 -variable stloptions.resthedgeanglefac
|
-variable stloptions.resthedgeanglefac
|
||||||
checkbutton $f.stl.r3b.bu -text "STL - edge angle" \
|
ttk::entry $f.stl.r3b.e -textvariable stloptions.resthedgeanglefac -width 3
|
||||||
-variable stloptions.resthedgeangleenable
|
ttk::checkbutton $f.stl.r3b.bu -text "STL - edge angle" \
|
||||||
pack $f.stl.r3b.sc $f.stl.r3b.bu -side left
|
-variable stloptions.resthedgeangleenable
|
||||||
|
pack $f.stl.r3b.sc $f.stl.r3b.e $f.stl.r3b.bu -side left -padx 4
|
||||||
|
|
||||||
frame $f.stl.r5
|
ttk::frame $f.stl.r5
|
||||||
pack $f.stl.r5 -anchor w
|
pack $f.stl.r5 -anchor w
|
||||||
scale $f.stl.r5.sc -orient horizontal -length 200 -from 0.2 -to 5 \
|
ttk::scale $f.stl.r5.sc -orient horizontal -length 150 -from 0.2 -to 5 \
|
||||||
-resolution 0.1 -variable stloptions.resthsurfmeshcurvfac
|
-variable stloptions.resthsurfmeshcurvfac
|
||||||
checkbutton $f.stl.r5.bu -text "STL - surface mesh curv" \
|
ttk::entry $f.stl.r5.e -textvariable stloptions.resthsurfmeshcurvfac -width 3
|
||||||
|
ttk::checkbutton $f.stl.r5.bu -text "STL - surface mesh curv" \
|
||||||
-variable stloptions.resthsurfmeshcurvenable
|
-variable stloptions.resthsurfmeshcurvenable
|
||||||
pack $f.stl.r5.sc $f.stl.r5.bu -side left
|
pack $f.stl.r5.sc $f.stl.r5.e $f.stl.r5.bu -side left -padx 4
|
||||||
|
|
||||||
|
|
||||||
checkbutton $f.stl.recalch -text "STL - Recalc mesh size for surface optimization" \
|
ttk::checkbutton $f.stl.recalch -text "STL - Recalc mesh size for surface optimization" \
|
||||||
-variable stloptions.recalchopt
|
-variable stloptions.recalchopt
|
||||||
pack $f.stl.recalch
|
pack $f.stl.recalch
|
||||||
|
|
||||||
button $f.stl.calch -text "Calc New H" -command { redraw; Ng_STLCalcLocalH }
|
ttk::button $f.stl.calch -text "Calc New H" -command { redraw; Ng_STLCalcLocalH }
|
||||||
pack $f.stl.calch
|
pack $f.stl.calch
|
||||||
|
|
||||||
|
|
||||||
@ -311,10 +422,11 @@ proc meshingoptionsdialog { } {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
set f [$w.nb subwidget chartopt]
|
# set f [$w.nb subwidget chartopt]
|
||||||
|
set f $w.nb.chartopt
|
||||||
|
|
||||||
label $f.lab1 -text "Yellow Edges Angle ()"
|
label $f.lab1 -text "Yellow Edges Angle ()" -bg [ttk::style lookup TNotebook -background]
|
||||||
|
#
|
||||||
scale $f.scale1 -orient horizontal -length 300 \
|
scale $f.scale1 -orient horizontal -length 300 \
|
||||||
-from 0 -to 90 -resolution 1 -tickinterval 10 \
|
-from 0 -to 90 -resolution 1 -tickinterval 10 \
|
||||||
-variable stloptions.yangle
|
-variable stloptions.yangle
|
||||||
@ -344,8 +456,8 @@ proc meshingoptionsdialog { } {
|
|||||||
|
|
||||||
# Optimization options
|
# Optimization options
|
||||||
|
|
||||||
set f [$w.nb subwidget optimizer]
|
# set f [$w.nb subwidget optimizer]
|
||||||
|
set f $w.nb.optimizer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -383,8 +495,9 @@ proc meshingoptionsdialog { } {
|
|||||||
|
|
||||||
pack $f.os2d $f.os3d $f.elw $f.wem
|
pack $f.os2d $f.os3d $f.elw $f.wem
|
||||||
|
|
||||||
frame $f.badellimit
|
ttk::frame $f.badellimit
|
||||||
pack $f.badellimit -fill x
|
pack $f.badellimit
|
||||||
|
# -fill x
|
||||||
label $f.badellimit.lab -text "bad element criterion";
|
label $f.badellimit.lab -text "bad element criterion";
|
||||||
scale $f.badellimit.scale -orient horizontal -length 150 \
|
scale $f.badellimit.scale -orient horizontal -length 150 \
|
||||||
-from 160 -to 180 -resolution 1 \
|
-from 160 -to 180 -resolution 1 \
|
||||||
@ -393,64 +506,68 @@ proc meshingoptionsdialog { } {
|
|||||||
|
|
||||||
|
|
||||||
# insider options
|
# insider options
|
||||||
set f [$w.nb subwidget insider]
|
# set f [$w.nb subwidget insider]
|
||||||
|
set f $w.nb.debug
|
||||||
|
ttk::frame $f.f2
|
||||||
|
pack $f.f2
|
||||||
checkbutton $f.localh -text "Use Local Meshsize" \
|
set f $f.f2
|
||||||
|
ttk::checkbutton $f.localh -text "Use Local Meshsize" \
|
||||||
-variable options.localh
|
-variable options.localh
|
||||||
checkbutton $f.delauney -text "Use Delaunay" \
|
ttk::checkbutton $f.delauney -text "Use Delaunay" \
|
||||||
-variable options.delaunay
|
-variable options.delaunay
|
||||||
checkbutton $f.checkoverlap -text "Check Overlapping" \
|
ttk::checkbutton $f.checkoverlap -text "Check Overlapping" \
|
||||||
-variable options.checkoverlap
|
-variable options.checkoverlap
|
||||||
checkbutton $f.checkcb -text "Check Chart Boundary" \
|
ttk::checkbutton $f.checkcb -text "Check Chart Boundary" \
|
||||||
-variable options.checkchartboundary
|
-variable options.checkchartboundary
|
||||||
checkbutton $f.blockfill -text "Do Blockfilling" \
|
ttk::checkbutton $f.blockfill -text "Do Blockfilling" \
|
||||||
-variable options.blockfill
|
-variable options.blockfill
|
||||||
|
|
||||||
pack $f.localh $f.delauney $f.checkoverlap $f.blockfill $f.checkcb -anchor w
|
# pack $f.localh $f.delauney $f.checkoverlap $f.blockfill $f.checkcb -anchor w
|
||||||
|
grid $f.localh $f.delauney -sticky nw
|
||||||
|
grid $f.checkoverlap $f.blockfill -sticky nw
|
||||||
|
grid $f.checkcb -sticky nw
|
||||||
|
|
||||||
|
|
||||||
# debugging options
|
# debugging options
|
||||||
set f [$w.nb subwidget debug]
|
# set f [$w.nb subwidget debug]
|
||||||
|
set f $w.nb.debug
|
||||||
|
|
||||||
frame $f.cb
|
ttk::frame $f.cb
|
||||||
pack $f.cb -side top
|
pack $f.cb -side top
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
checkbutton $f.cb.slowchecks -text "Slow checks" \
|
ttk::checkbutton $f.cb.slowchecks -text "Slow checks" \
|
||||||
-variable debug.slowchecks -command { Ng_SetDebugParameters }
|
-variable debug.slowchecks -command { Ng_SetDebugParameters }
|
||||||
checkbutton $f.cb.debugoutput -text "Debugging outout" \
|
ttk::checkbutton $f.cb.debugoutput -text "Debugging outout" \
|
||||||
-variable debug.debugoutput -command { Ng_SetDebugParameters }
|
-variable debug.debugoutput -command { Ng_SetDebugParameters }
|
||||||
checkbutton $f.cb.haltexline -text "Halt on exising line" \
|
ttk::checkbutton $f.cb.haltexline -text "Halt on exising line" \
|
||||||
-variable debug.haltexistingline -command { Ng_SetDebugParameters }
|
-variable debug.haltexistingline -command { Ng_SetDebugParameters }
|
||||||
checkbutton $f.cb.haltoverlap -text "Halt on Overlap" \
|
ttk::checkbutton $f.cb.haltoverlap -text "Halt on Overlap" \
|
||||||
-variable debug.haltoverlap -command { Ng_SetDebugParameters }
|
-variable debug.haltoverlap -command { Ng_SetDebugParameters }
|
||||||
checkbutton $f.cb.haltsuc -text "Halt on success" \
|
ttk::checkbutton $f.cb.haltsuc -text "Halt on success" \
|
||||||
-variable debug.haltsuccess -command { Ng_SetDebugParameters }
|
-variable debug.haltsuccess -command { Ng_SetDebugParameters }
|
||||||
checkbutton $f.cb.haltnosuc -text "Halt on no success" \
|
ttk::checkbutton $f.cb.haltnosuc -text "Halt on no success" \
|
||||||
-variable debug.haltnosuccess -command { Ng_SetDebugParameters }
|
-variable debug.haltnosuccess -command { Ng_SetDebugParameters }
|
||||||
checkbutton $f.cb.haltlargequal -text "Halt on large quality class" \
|
ttk::checkbutton $f.cb.haltlargequal -text "Halt on large quality class" \
|
||||||
-variable debug.haltlargequalclass -command { Ng_SetDebugParameters }
|
-variable debug.haltlargequalclass -command { Ng_SetDebugParameters }
|
||||||
checkbutton $f.cb.haltseg -text "Halt on Segment:" \
|
ttk::checkbutton $f.cb.haltseg -text "Halt on Segment:" \
|
||||||
-variable debug.haltsegment -command { Ng_SetDebugParameters }
|
-variable debug.haltsegment -command { Ng_SetDebugParameters }
|
||||||
checkbutton $f.cb.haltnode -text "Halt on Node:" \
|
ttk::checkbutton $f.cb.haltnode -text "Halt on Node:" \
|
||||||
-variable debug.haltnode -command { Ng_SetDebugParameters }
|
-variable debug.haltnode -command { Ng_SetDebugParameters }
|
||||||
|
|
||||||
|
|
||||||
pack $f.cb.slowchecks $f.cb.debugoutput $f.cb.haltexline $f.cb.haltoverlap $f.cb.haltsuc $f.cb.haltnosuc $f.cb.haltlargequal $f.cb.haltseg $f.cb.haltnode
|
pack $f.cb.slowchecks $f.cb.debugoutput $f.cb.haltexline $f.cb.haltoverlap
|
||||||
|
pack $f.cb.haltsuc $f.cb.haltnosuc $f.cb.haltlargequal $f.cb.haltseg $f.cb.haltnode
|
||||||
|
|
||||||
frame $f.cb.hf
|
ttk::frame $f.cb.hf
|
||||||
pack $f.cb.hf -pady 5
|
pack $f.cb.hf -pady 5
|
||||||
checkbutton $f.cb.hf.cb -text "Halt on Face:" \
|
ttk::checkbutton $f.cb.hf.cb -text "Halt on Face:" \
|
||||||
-variable debug.haltface -command { Ng_SetDebugParameters }
|
-variable debug.haltface -command { Ng_SetDebugParameters }
|
||||||
entry $f.cb.hf.ent -textvariable debug.haltfacenr -width 5
|
ttk::entry $f.cb.hf.ent -textvariable debug.haltfacenr -width 5
|
||||||
pack $f.cb.hf.cb $f.cb.hf.ent -side left
|
pack $f.cb.hf.cb $f.cb.hf.ent -side left
|
||||||
|
|
||||||
checkbutton $f.cb.showactivechart -text "Show Active Meshing-Chart" \
|
ttk::checkbutton $f.cb.showactivechart -text "Show Active Meshing-Chart" \
|
||||||
-variable stloptions.showactivechart -command { Ng_SetVisParameters; redraw }
|
-variable stloptions.showactivechart -command { Ng_SetVisParameters; redraw }
|
||||||
|
|
||||||
|
|
||||||
@ -459,31 +576,31 @@ proc meshingoptionsdialog { } {
|
|||||||
pack $f.cb.showactivechart
|
pack $f.cb.showactivechart
|
||||||
|
|
||||||
|
|
||||||
frame $f.segs
|
ttk::frame $f.segs
|
||||||
pack $f.segs -pady 5
|
pack $f.segs -pady 5
|
||||||
label $f.segs.lab1 -text "P1:";
|
ttk::label $f.segs.lab1 -text "P1:";
|
||||||
entry $f.segs.ent1 -width 8 -relief sunken \
|
ttk::entry $f.segs.ent1 -width 8 \
|
||||||
-textvariable debug.haltsegmentp1
|
-textvariable debug.haltsegmentp1
|
||||||
label $f.segs.lab2 -text "P2:";
|
ttk::label $f.segs.lab2 -text "P2:";
|
||||||
entry $f.segs.ent2 -width 8 -relief sunken \
|
ttk::entry $f.segs.ent2 -width 8 \
|
||||||
-textvariable debug.haltsegmentp2
|
-textvariable debug.haltsegmentp2
|
||||||
pack $f.segs.lab1 $f.segs.ent1 $f.segs.lab2 $f.segs.ent2 -side left
|
pack $f.segs.lab1 $f.segs.ent1 $f.segs.lab2 $f.segs.ent2 -side left
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
frame $f.cont -relief groove -borderwidth 3
|
ttk::frame $f.cont -relief groove -borderwidth 3
|
||||||
pack $f.cont
|
pack $f.cont
|
||||||
#-fill x
|
#-fill x
|
||||||
|
|
||||||
checkbutton $f.cont.multidrawing -text "Draw Meshing" \
|
ttk::checkbutton $f.cont.multidrawing -text "Draw Meshing" \
|
||||||
-variable multithread_drawing
|
-variable multithread_drawing
|
||||||
pack $f.cont.multidrawing
|
pack $f.cont.multidrawing
|
||||||
|
|
||||||
checkbutton $f.cont.multitestmode -text "Meshing Testmode" \
|
ttk::checkbutton $f.cont.multitestmode -text "Meshing Testmode" \
|
||||||
-variable multithread_testmode
|
-variable multithread_testmode
|
||||||
pack $f.cont.multitestmode
|
pack $f.cont.multitestmode
|
||||||
|
|
||||||
button $f.cont.goon -text "Go On" -command { set multithread_pause 0 }
|
ttk::button $f.cont.goon -text "Go On" -command { set multithread_pause 0 }
|
||||||
pack $f.cont.multidrawing $f.cont.multitestmode $f.cont.goon -side left -expand yes
|
pack $f.cont.multidrawing $f.cont.multitestmode $f.cont.goon -side left -expand yes
|
||||||
|
|
||||||
|
|
||||||
@ -526,28 +643,28 @@ proc meshingoptionsdialog { } {
|
|||||||
# pack $w.bbox -side bottom -fill x
|
# pack $w.bbox -side bottom -fill x
|
||||||
|
|
||||||
|
|
||||||
frame $w.bu
|
ttk::frame $w.bu
|
||||||
pack $w.bu -fill x -ipady 3
|
pack $w.bu -fill x -ipady 3
|
||||||
|
|
||||||
button $w.bu.apl -text "Apply" -command {
|
ttk::button $w.bu.apl -text "Apply" -command {
|
||||||
[.options_dlg.nb subwidget meshsize].meshsize invoke
|
# .options_dlg.nb.meshsize.meshsize invoke
|
||||||
[.options_dlg.nb subwidget meshsize].grading invoke
|
# .options_dlg.nb.meshsize.grading invoke
|
||||||
[.options_dlg.nb subwidget optimizer].os2d invoke
|
.options_dlg.nb.optimizer.os2d invoke
|
||||||
[.options_dlg.nb subwidget optimizer].os3d invoke
|
.options_dlg.nb.optimizer.os3d invoke
|
||||||
[.options_dlg.nb subwidget optimizer].elw invoke
|
.options_dlg.nb.optimizer.elw invoke
|
||||||
[.options_dlg.nb subwidget optimizer].wem invoke
|
.options_dlg.nb.optimizer.wem invoke
|
||||||
|
|
||||||
Ng_SetMeshingParameters
|
Ng_SetMeshingParameters
|
||||||
Ng_SetDebugParameters
|
Ng_SetDebugParameters
|
||||||
}
|
}
|
||||||
|
|
||||||
button $w.bu.ok -text "Done" -command {
|
ttk::button $w.bu.ok -text "Done" -command {
|
||||||
[.options_dlg.nb subwidget meshsize].meshsize invoke
|
# .options_dlg.nb.meshsize.meshsize invoke
|
||||||
[.options_dlg.nb subwidget meshsize].grading invoke
|
# .options_dlg.nb.meshsize.grading invoke
|
||||||
[.options_dlg.nb subwidget optimizer].os2d invoke
|
.options_dlg.nb.optimizer.os2d invoke
|
||||||
[.options_dlg.nb subwidget optimizer].os3d invoke
|
.options_dlg.nb.optimizer.os3d invoke
|
||||||
[.options_dlg.nb subwidget optimizer].elw invoke
|
.options_dlg.nb.optimizer.elw invoke
|
||||||
[.options_dlg.nb subwidget optimizer].wem invoke
|
.options_dlg.nb.optimizer.wem invoke
|
||||||
|
|
||||||
Ng_SetMeshingParameters
|
Ng_SetMeshingParameters
|
||||||
Ng_SetDebugParameters
|
Ng_SetDebugParameters
|
||||||
@ -595,43 +712,51 @@ proc viewingoptionsdialog { } {
|
|||||||
focus $w
|
focus $w
|
||||||
} {
|
} {
|
||||||
toplevel $w
|
toplevel $w
|
||||||
|
wm resizable $w 0 0
|
||||||
|
|
||||||
|
|
||||||
|
pack [ttk::notebook $w.nb] -fill both -fill both -side top
|
||||||
|
$w.nb add [ttk::frame $w.nb.general] -text "General" -underline 0
|
||||||
|
$w.nb add [ttk::frame $w.nb.stl] -text "STL" -underline 0
|
||||||
|
$w.nb add [ttk::frame $w.nb.occ] -text "IGES/STEP" -underline 0
|
||||||
|
$w.nb add [ttk::frame $w.nb.mesh] -text "Mesh" -underline 0
|
||||||
|
$w.nb add [ttk::frame $w.nb.light] -text "Light" -underline 0
|
||||||
|
$w.nb add [ttk::frame $w.nb.edges] -text "Edges" -underline 0
|
||||||
|
$w.nb add [ttk::frame $w.nb.misc] -text "Misc." -underline 3
|
||||||
|
|
||||||
|
|
||||||
|
# tixNoteBook $w.nb -ipadx 6 -ipady 6
|
||||||
|
|
||||||
tixNoteBook $w.nb -ipadx 6 -ipady 6
|
|
||||||
|
|
||||||
$w.nb add general -label "General" -underline 0
|
# $w.nb add general -label "General" -underline 0
|
||||||
$w.nb add stl -label "STL" -underline 0
|
# $w.nb add stl -label "STL" -underline 0
|
||||||
$w.nb add occ -label "IGES/STEP" -underline 0
|
# $w.nb add occ -label "IGES/STEP" -underline 0
|
||||||
$w.nb add mesh -label "Mesh" -underline 0
|
# $w.nb add mesh -label "Mesh" -underline 0
|
||||||
$w.nb add light -label "Light" -underline 0
|
# $w.nb add light -label "Light" -underline 0
|
||||||
$w.nb add edges -label "Edges" -underline 0
|
# $w.nb add edges -label "Edges" -underline 0
|
||||||
$w.nb add misc -label "Misc." -underline 3
|
# $w.nb add misc -label "Misc." -underline 3
|
||||||
|
|
||||||
|
# pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top
|
||||||
pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# general
|
# general
|
||||||
set f [$w.nb subwidget general]
|
set f $w.nb.general
|
||||||
|
|
||||||
checkbutton $f.backcol -text "White Background" \
|
ttk::checkbutton $f.backcol -text "White Background" \
|
||||||
-variable viewoptions.whitebackground \
|
-variable viewoptions.whitebackground \
|
||||||
-command { Ng_SetVisParameters; redraw }
|
-command { Ng_SetVisParameters; redraw }
|
||||||
|
|
||||||
checkbutton $f.cross -text "Draw Coordinate Cross" \
|
ttk::checkbutton $f.cross -text "Draw Coordinate Cross" \
|
||||||
-variable viewoptions.drawcoordinatecross \
|
-variable viewoptions.drawcoordinatecross \
|
||||||
-command { Ng_SetVisParameters; redraw }
|
-command { Ng_SetVisParameters; redraw }
|
||||||
|
|
||||||
checkbutton $f.color -text "Draw Color-bar" \
|
ttk::checkbutton $f.color -text "Draw Color-bar" \
|
||||||
-variable viewoptions.drawcolorbar \
|
-variable viewoptions.drawcolorbar \
|
||||||
-command { Ng_SetVisParameters; redraw }
|
-command { Ng_SetVisParameters; redraw }
|
||||||
|
|
||||||
checkbutton $f.netgen -text "Draw Netgen-logo" \
|
ttk::checkbutton $f.netgen -text "Draw Netgen-logo" \
|
||||||
-variable viewoptions.drawnetgenlogo \
|
-variable viewoptions.drawnetgenlogo \
|
||||||
-command { Ng_SetVisParameters; redraw }
|
-command { Ng_SetVisParameters; redraw }
|
||||||
|
|
||||||
@ -642,8 +767,19 @@ proc viewingoptionsdialog { } {
|
|||||||
# -command { Ng_SetVisParameters; redraw }
|
# -command { Ng_SetVisParameters; redraw }
|
||||||
# pack $f.stereo
|
# pack $f.stereo
|
||||||
|
|
||||||
|
|
||||||
|
menu $f.stylemenu
|
||||||
|
ttk::menubutton $f.style -menu $f.stylemenu
|
||||||
|
# -text [ttk::getTheme]
|
||||||
|
pack $f.style
|
||||||
|
|
||||||
|
foreach theme [ttk::themes] {
|
||||||
|
$f.stylemenu add command -label $theme \
|
||||||
|
-command " $f.style configure -text $theme; puts $theme ; ttk::setTheme $theme"
|
||||||
|
}
|
||||||
|
|
||||||
# stl geometry
|
# stl geometry
|
||||||
set f [$w.nb subwidget stl]
|
set f $w.nb.stl
|
||||||
|
|
||||||
frame $f.show -relief groove -borderwidth 3
|
frame $f.show -relief groove -borderwidth 3
|
||||||
pack $f.show
|
pack $f.show
|
||||||
@ -747,7 +883,7 @@ proc viewingoptionsdialog { } {
|
|||||||
|
|
||||||
|
|
||||||
# IGES/STEP
|
# IGES/STEP
|
||||||
set f [$w.nb subwidget occ]
|
set f $w.nb.occ
|
||||||
|
|
||||||
checkbutton $f.occshowsurfaces -text "Show surfaces " \
|
checkbutton $f.occshowsurfaces -text "Show surfaces " \
|
||||||
-variable occoptions.showsurfaces \
|
-variable occoptions.showsurfaces \
|
||||||
@ -809,7 +945,7 @@ proc viewingoptionsdialog { } {
|
|||||||
|
|
||||||
|
|
||||||
# mesh options
|
# mesh options
|
||||||
set f [$w.nb subwidget mesh]
|
set f $w.nb.mesh
|
||||||
|
|
||||||
checkbutton $f.showcolor -text "Colored Meshsize Visualization" \
|
checkbutton $f.showcolor -text "Colored Meshsize Visualization" \
|
||||||
-variable viewoptions.colormeshsize \
|
-variable viewoptions.colormeshsize \
|
||||||
@ -960,7 +1096,7 @@ proc viewingoptionsdialog { } {
|
|||||||
|
|
||||||
|
|
||||||
# light options
|
# light options
|
||||||
set f [$w.nb subwidget light]
|
set f $w.nb.light
|
||||||
|
|
||||||
label $f.lab1 -text "Ambient Light"
|
label $f.lab1 -text "Ambient Light"
|
||||||
scale $f.scale1 -orient horizontal -length 300 -from 0 -to 1 \
|
scale $f.scale1 -orient horizontal -length 300 -from 0 -to 1 \
|
||||||
@ -990,7 +1126,7 @@ proc viewingoptionsdialog { } {
|
|||||||
|
|
||||||
|
|
||||||
# edges options
|
# edges options
|
||||||
set f [$w.nb subwidget edges]
|
set f $w.nb.edges
|
||||||
|
|
||||||
checkbutton $f.showedges -text "Show Edges" \
|
checkbutton $f.showedges -text "Show Edges" \
|
||||||
-variable viewoptions.drawededges \
|
-variable viewoptions.drawededges \
|
||||||
@ -1030,7 +1166,7 @@ proc viewingoptionsdialog { } {
|
|||||||
|
|
||||||
|
|
||||||
# misc options
|
# misc options
|
||||||
set f [$w.nb subwidget misc]
|
set f $w.nb.misc
|
||||||
|
|
||||||
frame $f.point -relief groove -borderwidth 3
|
frame $f.point -relief groove -borderwidth 3
|
||||||
|
|
||||||
@ -1070,16 +1206,16 @@ proc viewingoptionsdialog { } {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
frame $w.bu
|
ttk::frame $w.bu
|
||||||
pack $w.bu -fill x -ipady 3
|
pack $w.bu -fill x -ipady 3
|
||||||
|
|
||||||
|
|
||||||
button $w.bu.done -text "Done" -command {
|
ttk::button $w.bu.done -text "Done" -command {
|
||||||
Ng_SetVisParameters;
|
Ng_SetVisParameters;
|
||||||
redraw
|
redraw
|
||||||
destroy .viewopts_dlg
|
destroy .viewopts_dlg
|
||||||
}
|
}
|
||||||
button $w.bu.apply -text "Apply" -command {
|
ttk::button $w.bu.apply -text "Apply" -command {
|
||||||
Ng_SetVisParameters;
|
Ng_SetVisParameters;
|
||||||
redraw
|
redraw
|
||||||
}
|
}
|
||||||
@ -1677,7 +1813,8 @@ proc stloptionsdialog { } {
|
|||||||
} {
|
} {
|
||||||
toplevel $w
|
toplevel $w
|
||||||
|
|
||||||
tixNoteBook $w.nb -ipadx 6 -ipady 6
|
pack [ttk::notebook $w.nb] -fill both -fill both -side top
|
||||||
|
# tixNoteBook $w.nb -ipadx 6 -ipady 6
|
||||||
# $w config -bg gray
|
# $w config -bg gray
|
||||||
# $w.nb subwidget nbframe config -backpagecolor gray
|
# $w.nb subwidget nbframe config -backpagecolor gray
|
||||||
|
|
||||||
@ -1772,22 +1909,25 @@ proc stldoctordialog { } {
|
|||||||
|
|
||||||
toplevel $wd
|
toplevel $wd
|
||||||
|
|
||||||
tixNoteBook $wd.nb -ipadx 6 -ipady 6
|
pack [ttk::notebook $wd.nb] -fill both -fill both -side top
|
||||||
|
$wd.nb add [ttk::frame $wd.nb.general] -text "General" -underline 0
|
||||||
$wd.nb add general -label "General" -underline 0
|
$wd.nb add [ttk::frame $wd.nb.topology] -text "Edit Topology" -underline 5
|
||||||
$wd.nb add topology -label "Edit Topology" -underline 5
|
$wd.nb add [ttk::frame $wd.nb.edges] -text "Edit Edges" -underline 5
|
||||||
$wd.nb add edges -label "Edit Edges" -underline 5
|
$wd.nb add [ttk::frame $wd.nb.normals] -text "Edit Normals" -underline 5
|
||||||
$wd.nb add normals -label "Edit Normals" -underline 5
|
$wd.nb add [ttk::frame $wd.nb.advanced] -text "Advanced" -underline 0
|
||||||
$wd.nb add advanced -label "Advanced" -underline 0
|
|
||||||
|
# tixNoteBook $wd.nb -ipadx 6 -ipady 6
|
||||||
|
# $wd.nb add general -label "General" -underline 0
|
||||||
pack $wd.nb -expand yes -fill both -padx 5 -pady 5 -side top
|
# $wd.nb add topology -label "Edit Topology" -underline 5
|
||||||
|
# $wd.nb add edges -label "Edit Edges" -underline 5
|
||||||
|
# $wd.nb add normals -label "Edit Normals" -underline 5
|
||||||
|
# $wd.nb add advanced -label "Advanced" -underline 0
|
||||||
|
# pack $wd.nb -expand yes -fill both -padx 5 -pady 5 -side top
|
||||||
|
|
||||||
|
|
||||||
# GENERAL *****************************
|
# GENERAL *****************************
|
||||||
|
|
||||||
set f [$wd.nb subwidget general]
|
set f $wd.nb.general
|
||||||
|
|
||||||
|
|
||||||
frame $f.show
|
frame $f.show
|
||||||
pack $f.show -fill x
|
pack $f.show -fill x
|
||||||
@ -1858,7 +1998,7 @@ proc stldoctordialog { } {
|
|||||||
pack $f.ge.cancle -expand yes
|
pack $f.ge.cancle -expand yes
|
||||||
|
|
||||||
# TOPOLOGY ********************
|
# TOPOLOGY ********************
|
||||||
set f [$wd.nb subwidget topology]
|
set f $wd.nb.topology
|
||||||
|
|
||||||
frame $f.oc -relief groove -borderwidth 3
|
frame $f.oc -relief groove -borderwidth 3
|
||||||
pack $f.oc -fill x
|
pack $f.oc -fill x
|
||||||
@ -1878,7 +2018,7 @@ proc stldoctordialog { } {
|
|||||||
|
|
||||||
|
|
||||||
# EDGES ***********************
|
# EDGES ***********************
|
||||||
set f [$wd.nb subwidget edges]
|
set f $wd.nb.edges
|
||||||
|
|
||||||
|
|
||||||
frame $f.be -relief groove -borderwidth 3
|
frame $f.be -relief groove -borderwidth 3
|
||||||
@ -2030,7 +2170,7 @@ proc stldoctordialog { } {
|
|||||||
|
|
||||||
|
|
||||||
# NORMALS ***********************
|
# NORMALS ***********************
|
||||||
set f [$wd.nb subwidget normals]
|
set f $wd.nb.normals
|
||||||
|
|
||||||
frame $f.dt -relief groove -borderwidth 3
|
frame $f.dt -relief groove -borderwidth 3
|
||||||
pack $f.dt -fill x
|
pack $f.dt -fill x
|
||||||
@ -2077,7 +2217,7 @@ proc stldoctordialog { } {
|
|||||||
|
|
||||||
|
|
||||||
# ADVANCED **************************
|
# ADVANCED **************************
|
||||||
set f [$wd.nb subwidget advanced]
|
set f $wd.nb.advanced
|
||||||
|
|
||||||
|
|
||||||
frame $f.sc
|
frame $f.sc
|
||||||
@ -2101,7 +2241,7 @@ proc stldoctordialog { } {
|
|||||||
pack $f.gtol
|
pack $f.gtol
|
||||||
|
|
||||||
button $f.adap -text "Apply" -command {
|
button $f.adap -text "Apply" -command {
|
||||||
[.stldoctor_dlg.nb subwidget advanced].gtol invoke
|
.stldoctor_dlg.nb.advanced.gtol invoke
|
||||||
Ng_STLDoctor;
|
Ng_STLDoctor;
|
||||||
}
|
}
|
||||||
pack $f.adap -expand yes
|
pack $f.adap -expand yes
|
||||||
|
@ -9,12 +9,41 @@ set oldmousey 0
|
|||||||
# if { 1 } {
|
# if { 1 } {
|
||||||
|
|
||||||
# use this one for Togl 2.0
|
# use this one for Togl 2.0
|
||||||
# if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect false -create init -display draw -reshape reshape }] } {
|
#if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect false }] } {
|
||||||
|
|
||||||
if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect false }] } { puts "no OpenGL"
|
# if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect false -create init -display draw -reshape reshape }] } {
|
||||||
|
# puts "no OpenGL"
|
||||||
|
# } {
|
||||||
|
|
||||||
|
puts "********* query toglversion *******"
|
||||||
|
set toglversion [Ng_GetToglVersion]
|
||||||
|
puts "togl-version : $toglversion"
|
||||||
|
|
||||||
|
set toglok 0
|
||||||
|
if { [Ng_GetToglVersion] == 2 } {
|
||||||
|
# Togl 2.x
|
||||||
|
if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect false -create init -display draw -reshape reshape }] } {
|
||||||
|
puts "no OpenGL"
|
||||||
|
} {
|
||||||
|
# puts "have Togl 2.1"
|
||||||
|
set toglok 1
|
||||||
|
}
|
||||||
} {
|
} {
|
||||||
|
# Togl 1.7
|
||||||
|
if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect false }] } {
|
||||||
|
puts "no OpenGL"
|
||||||
|
} {
|
||||||
|
# puts "have Togl 1.7"
|
||||||
|
set toglok 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if { $toglok == 1} {
|
||||||
|
puts "***** togl is ok ********"
|
||||||
|
|
||||||
#
|
#
|
||||||
pack .ndraw -expand true -fill both -padx 10 -pady 10
|
pack .ndraw -expand true -fill both -padx 10 -pady 10
|
||||||
|
catch { tkdnd::drop_target register .ndraw DND_Files }
|
||||||
#
|
#
|
||||||
bind .ndraw <Button-1> {
|
bind .ndraw <Button-1> {
|
||||||
set oldmousex %x; set oldmousey %y;
|
set oldmousex %x; set oldmousey %y;
|
||||||
@ -115,3 +144,52 @@ bind . <Button-5> \
|
|||||||
|
|
||||||
bind . <MouseWheel> { Ng_MouseMove 0 0 0 [expr {%D/-5}] zoom; redraw }
|
bind . <MouseWheel> { Ng_MouseMove 0 0 0 [expr {%D/-5}] zoom; redraw }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Drop callbacks:
|
||||||
|
bind .ndraw <<Drop:DND_Files>> {
|
||||||
|
#tk_messageBox -message "Dropped files: \"[join %D {, }]\""
|
||||||
|
#%W state !active
|
||||||
|
set index [string first . %D end-6]
|
||||||
|
#tk_messageBox -message $index
|
||||||
|
set type [string range %D $index+1 end]
|
||||||
|
# tk_messageBox -message $type
|
||||||
|
set ispde [string match -nocase $type "pde"]
|
||||||
|
set isgeo [expr max([string match -nocase $type "geo"],[string match -nocase $type "in2d"])]
|
||||||
|
set ismesh [expr max([string match -nocase $type "vol"],[string match -nocase $type "vol.gz"])]
|
||||||
|
set ispy [string match -nocase $type "py"]
|
||||||
|
if {$ispde == 1} {
|
||||||
|
AddRecentNGSFile %D;
|
||||||
|
NGS_LoadPDE %D;
|
||||||
|
SetNumProcHelpMenu
|
||||||
|
set selectvisual mesh;
|
||||||
|
Ng_SetVisParameters
|
||||||
|
}
|
||||||
|
if {$ispy == 1} {
|
||||||
|
AddRecentPYNGSFile %D;
|
||||||
|
NGS_LoadPy %D;
|
||||||
|
}
|
||||||
|
if {$isgeo == 1} {
|
||||||
|
AddRecentFile %D;
|
||||||
|
Ng_LoadGeometry %D;
|
||||||
|
Ng_ParseGeometry
|
||||||
|
set selectvisual geometry
|
||||||
|
Ng_SetVisParameters
|
||||||
|
redraw
|
||||||
|
wm title . [concat "$progname - " %D]
|
||||||
|
set dirname [file dirname %D]
|
||||||
|
set basefilename [file tail [file rootname %D]]
|
||||||
|
}
|
||||||
|
if {$ismesh == 1} {
|
||||||
|
AddRecentMeshFile %D;
|
||||||
|
Ng_LoadMesh %D;
|
||||||
|
set selectvisual mesh
|
||||||
|
Ng_SetVisParameters
|
||||||
|
redraw
|
||||||
|
Ng_ReadStatus;
|
||||||
|
wm title . [concat "$progname - " %D]
|
||||||
|
set dirname [file dirname %D]
|
||||||
|
set basefilename [file tail [file rootname %D]]
|
||||||
|
}
|
||||||
|
return %A
|
||||||
|
}
|
||||||
|
166
ng/drawing_togl17.tcl
Normal file
166
ng/drawing_togl17.tcl
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
#
|
||||||
|
# Creates a drawing frame, and binds mouse events
|
||||||
|
#
|
||||||
|
set oldmousex 0
|
||||||
|
set oldmousey 0
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
# if { 1 } {
|
||||||
|
|
||||||
|
|
||||||
|
if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect false }] } {
|
||||||
|
puts "no OpenGL"
|
||||||
|
} {
|
||||||
|
#
|
||||||
|
pack .ndraw -expand true -fill both -padx 10 -pady 10
|
||||||
|
catch { tkdnd::drop_target register .ndraw DND_Files }
|
||||||
|
#
|
||||||
|
bind .ndraw <Button-1> {
|
||||||
|
set oldmousex %x; set oldmousey %y;
|
||||||
|
}
|
||||||
|
bind .ndraw <Button-2> {
|
||||||
|
set oldmousex %x; set oldmousey %y;
|
||||||
|
}
|
||||||
|
bind .ndraw <Button-3> {
|
||||||
|
set oldmousex %x; set oldmousey %y;
|
||||||
|
}
|
||||||
|
bind .ndraw <B1-Motion> {
|
||||||
|
Ng_MouseMove $oldmousex $oldmousey %x %y $drawmode
|
||||||
|
.ndraw render
|
||||||
|
set oldmousex %x; set oldmousey %y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bind .ndraw <Double-1> {
|
||||||
|
Ng_MouseDblClick %x %y
|
||||||
|
.ndraw render
|
||||||
|
if { [winfo exists .bcprop_dlg] } { bcpropdialog }
|
||||||
|
if { [winfo exists .surfacemeshsize_dlg] } { surfacemeshsizedialog }
|
||||||
|
if { [winfo exists .fieldlines_dlg] } { fieldlinesdialog }
|
||||||
|
}
|
||||||
|
|
||||||
|
bind .ndraw <B2-Motion> {
|
||||||
|
Ng_MouseMove $oldmousex $oldmousey %x %y move
|
||||||
|
.ndraw render
|
||||||
|
set oldmousex %x; set oldmousey %y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bind .ndraw <B3-Motion> {
|
||||||
|
if { $tcl_platform(os) == "Darwin" } {
|
||||||
|
Ng_MouseMove $oldmousex $oldmousey %x %y move
|
||||||
|
} {
|
||||||
|
Ng_MouseMove $oldmousex $oldmousey %x %y zoom
|
||||||
|
}
|
||||||
|
.ndraw render
|
||||||
|
set oldmousex %x; set oldmousey %y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
proc popupcheckredraw { vari { x 0 } } {
|
||||||
|
upvar $vari varname
|
||||||
|
if { $varname == 1 } {
|
||||||
|
set varname 0
|
||||||
|
} {
|
||||||
|
# puts "popup-redraw $vari"
|
||||||
|
Ng_Vis_Set parameters
|
||||||
|
redraw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
proc popupcheckredraw2 { vari boolvar { x 0 } } {
|
||||||
|
upvar $vari varname
|
||||||
|
if { $varname == 1 } {
|
||||||
|
set varname 0
|
||||||
|
} {
|
||||||
|
Ng_SetVisParameters
|
||||||
|
Ng_Vis_Set parameters
|
||||||
|
if { $boolvar == 1 } { redraw }
|
||||||
|
Ng_SetVisParameters
|
||||||
|
}
|
||||||
|
}
|
||||||
|
proc popupcheckredraw3 { vari { x 0 } } {
|
||||||
|
upvar $vari varname
|
||||||
|
if { $varname == 1 } {
|
||||||
|
set varname 0
|
||||||
|
} {
|
||||||
|
Ng_Vis_Set parameters
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
proc redraw { {x 0} } {
|
||||||
|
if {[winfo exists .ndraw]} { .ndraw render }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bind . <Left> { Ng_MouseMove 0 0 -10 0 rotate; redraw }
|
||||||
|
bind . <Right> { Ng_MouseMove 0 0 10 0 rotate; redraw }
|
||||||
|
bind . <Up> { Ng_MouseMove 0 0 0 -10 rotate; redraw }
|
||||||
|
bind . <Down> { Ng_MouseMove 0 0 0 10 rotate; redraw }
|
||||||
|
bind . <Shift-Left> { Ng_MouseMove 0 0 -10 0 move; redraw }
|
||||||
|
bind . <Shift-Right> { Ng_MouseMove 0 0 10 0 move; redraw }
|
||||||
|
bind . <Shift-Up> { Ng_MouseMove 0 0 0 -10 move; redraw }
|
||||||
|
bind . <Shift-Down> { Ng_MouseMove 0 0 0 10 move; redraw }
|
||||||
|
bind . <Control-Up> { Ng_MouseMove 0 0 0 -10 zoom; redraw }
|
||||||
|
bind . <Control-Down> { Ng_MouseMove 0 0 0 10 zoom; redraw }
|
||||||
|
|
||||||
|
bind . <Button-4> \
|
||||||
|
{event generate [focus -displayof %W] <MouseWheel> -delta 120}
|
||||||
|
|
||||||
|
bind . <Button-5> \
|
||||||
|
{event generate [focus -displayof %W] <MouseWheel> -delta -120}
|
||||||
|
|
||||||
|
bind . <MouseWheel> { Ng_MouseMove 0 0 0 [expr {%D/-5}] zoom; redraw }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Drop callbacks:
|
||||||
|
bind .ndraw <<Drop:DND_Files>> {
|
||||||
|
#tk_messageBox -message "Dropped files: \"[join %D {, }]\""
|
||||||
|
#%W state !active
|
||||||
|
set index [string first . %D end-6]
|
||||||
|
#tk_messageBox -message $index
|
||||||
|
set type [string range %D $index+1 end]
|
||||||
|
# tk_messageBox -message $type
|
||||||
|
set ispde [string match -nocase $type "pde"]
|
||||||
|
set isgeo [expr max([string match -nocase $type "geo"],[string match -nocase $type "in2d"])]
|
||||||
|
set ismesh [expr max([string match -nocase $type "vol"],[string match -nocase $type "vol.gz"])]
|
||||||
|
set ispy [string match -nocase $type "py"]
|
||||||
|
if {$ispde == 1} {
|
||||||
|
AddRecentNGSFile %D;
|
||||||
|
NGS_LoadPDE %D;
|
||||||
|
SetNumProcHelpMenu
|
||||||
|
set selectvisual mesh;
|
||||||
|
Ng_SetVisParameters
|
||||||
|
}
|
||||||
|
if {$ispy == 1} {
|
||||||
|
AddRecentPYNGSFile %D;
|
||||||
|
NGS_LoadPy %D;
|
||||||
|
}
|
||||||
|
if {$isgeo == 1} {
|
||||||
|
AddRecentFile %D;
|
||||||
|
Ng_LoadGeometry %D;
|
||||||
|
Ng_ParseGeometry
|
||||||
|
set selectvisual geometry
|
||||||
|
Ng_SetVisParameters
|
||||||
|
redraw
|
||||||
|
wm title . [concat "$progname - " %D]
|
||||||
|
set dirname [file dirname %D]
|
||||||
|
set basefilename [file tail [file rootname %D]]
|
||||||
|
}
|
||||||
|
if {$ismesh == 1} {
|
||||||
|
AddRecentMeshFile %D;
|
||||||
|
Ng_LoadMesh %D;
|
||||||
|
set selectvisual mesh
|
||||||
|
Ng_SetVisParameters
|
||||||
|
redraw
|
||||||
|
Ng_ReadStatus;
|
||||||
|
wm title . [concat "$progname - " %D]
|
||||||
|
set dirname [file dirname %D]
|
||||||
|
set basefilename [file tail [file rootname %D]]
|
||||||
|
}
|
||||||
|
return %A
|
||||||
|
}
|
2357
ng/fonts.hpp
Normal file
2357
ng/fonts.hpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -103,7 +103,7 @@ menu .ngmenu.file
|
|||||||
|
|
||||||
|
|
||||||
.ngmenu.file add cascade -label "Recent Files" -menu .ngmenu.file.recent
|
.ngmenu.file add cascade -label "Recent Files" -menu .ngmenu.file.recent
|
||||||
menu .ngmenu.file.recent
|
menu .ngmenu.file.recent -tearoff 0
|
||||||
|
|
||||||
|
|
||||||
proc AddRecentFile { filename } {
|
proc AddRecentFile { filename } {
|
||||||
@ -815,11 +815,13 @@ tk_messageBox -message "This is NETGEN \nmainly written by \nJoachim Schoeberl \
|
|||||||
# #
|
# #
|
||||||
#####################################################
|
#####################################################
|
||||||
|
|
||||||
frame .bubar -relief raised -bd 2
|
ttk::frame .bubar
|
||||||
|
# -relief raised
|
||||||
|
#-relief raised -bd 2
|
||||||
pack .bubar -side top -fill x
|
pack .bubar -side top -fill x
|
||||||
|
|
||||||
button .bubar.testb -text "Test" -command { Ng_SaveGeometry }
|
button .bubar.testb -text "Test" -command { Ng_SaveGeometry }
|
||||||
button .bubar.surfm -text "Generate Mesh" -command \
|
ttk::button .bubar.surfm -text "Generate Mesh" -command \
|
||||||
{
|
{
|
||||||
.ngmenu.mesh invoke "Generate Mesh";
|
.ngmenu.mesh invoke "Generate Mesh";
|
||||||
# set selectvisual mesh;
|
# set selectvisual mesh;
|
||||||
@ -827,13 +829,13 @@ button .bubar.surfm -text "Generate Mesh" -command \
|
|||||||
# Ng_GenerateMesh ${meshoptions.firststep} ${meshoptions.laststep}
|
# Ng_GenerateMesh ${meshoptions.firststep} ${meshoptions.laststep}
|
||||||
# redraw
|
# redraw
|
||||||
}
|
}
|
||||||
button .bubar.stopm -text "Stop" -command \
|
ttk::button .bubar.stopm -text "Stop" -command \
|
||||||
{
|
{
|
||||||
# Ng_StopMeshing;
|
# Ng_StopMeshing;
|
||||||
set multithread_terminate 1;
|
set multithread_terminate 1;
|
||||||
set stopdemo 1;
|
set stopdemo 1;
|
||||||
}
|
}
|
||||||
button .bubar.exitb -text "Quit" \
|
ttk::button .bubar.exitb -text "Quit" \
|
||||||
-command {
|
-command {
|
||||||
set ans [tk_messageBox -title "Quit Netgen?" -message "Do you really want to quit Netgen?" -type yesno -default "no" -icon question]
|
set ans [tk_messageBox -title "Quit Netgen?" -message "Do you really want to quit Netgen?" -type yesno -default "no" -icon question]
|
||||||
if { $ans == "yes" } {
|
if { $ans == "yes" } {
|
||||||
@ -845,20 +847,20 @@ pack .bubar.exitb .bubar.surfm .bubar.stopm -side left
|
|||||||
#button .bubar.scan -text "Scan" \
|
#button .bubar.scan -text "Scan" \
|
||||||
# -command { Ng_ParseGeometry; set selectvisual geometry; Ng_SetVisParameters; redraw }
|
# -command { Ng_ParseGeometry; set selectvisual geometry; Ng_SetVisParameters; redraw }
|
||||||
|
|
||||||
button .bubar.zoomall -text "Zoom All" \
|
ttk::button .bubar.zoomall -text "Zoom All" \
|
||||||
-command { Ng_ZoomAll; redraw }
|
-command { Ng_ZoomAll; redraw }
|
||||||
|
|
||||||
button .bubar.center -text "Center" \
|
ttk::button .bubar.center -text "Center" \
|
||||||
-command { Ng_Center; redraw }
|
-command { Ng_Center; redraw }
|
||||||
|
|
||||||
# tk_optionMenu .bubar.modesel drawmode "rotate" "move " "zoom "
|
# tk_optionMenu .bubar.modesel drawmode "rotate" "move " "zoom "
|
||||||
tixOptionMenu .bubar.modesel \
|
tixOptionMenu .bubar.modesel \
|
||||||
-options {
|
-options {
|
||||||
label.width 0
|
label.width 0
|
||||||
label.anchor e
|
label.anchor e
|
||||||
menubutton.width 6
|
menubutton.width 6
|
||||||
} \
|
} \
|
||||||
-variable drawmode
|
-variable drawmode
|
||||||
|
|
||||||
.bubar.modesel add command rotate -label Rotate
|
.bubar.modesel add command rotate -label Rotate
|
||||||
.bubar.modesel add command move -label Move
|
.bubar.modesel add command move -label Move
|
||||||
@ -890,15 +892,15 @@ foreach viewv $viewvals {
|
|||||||
.bubar.selview add command $viewv -label $viewvallabs($viewv)
|
.bubar.selview add command $viewv -label $viewvallabs($viewv)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.bubar.selview config -variable selectvisual
|
.bubar.selview config -variable selectvisual
|
||||||
.bubar.selview config -command { Ng_SetVisParameters; redraw }
|
.bubar.selview config -command { Ng_SetVisParameters; redraw }
|
||||||
|
|
||||||
|
|
||||||
pack .bubar.modesel -side right
|
# pack .bubar.modesel -side right
|
||||||
pack forget .bubar.modesel
|
# pack forget .bubar.modesel
|
||||||
pack .bubar.center .bubar.zoomall .bubar.selview -side right
|
|
||||||
|
pack .bubar.center .bubar.zoomall -side right
|
||||||
|
# pack .bubar.selview -side right
|
||||||
|
|
||||||
.ngmenu.view add checkbutton -variable viewrotatebutton \
|
.ngmenu.view add checkbutton -variable viewrotatebutton \
|
||||||
-label "Enable LeftButton Selection" \
|
-label "Enable LeftButton Selection" \
|
||||||
@ -910,7 +912,22 @@ pack .bubar.center .bubar.zoomall .bubar.selview -side right
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
puts "bubar selviewmenu"
|
||||||
|
menu .bubar.selviewmenu
|
||||||
|
ttk::menubutton .bubar.selview1 -menu .bubar.selviewmenu -text "Geometry"
|
||||||
|
foreach viewv $viewvals {
|
||||||
|
.bubar.selviewmenu add command -label $viewvallabs($viewv) -command \
|
||||||
|
".bubar.selview1 configure -text \"$viewvallabs($viewv)\" ; set selectvisual $viewv ; Ng_SetVisParameters; redraw"
|
||||||
|
}
|
||||||
|
pack .bubar.selview1 -side right
|
||||||
|
# .bubar.selviewmenu invoke $viewvallabs($selectvisual)
|
||||||
|
|
||||||
|
trace add variable selectvisual write selvis_monitor
|
||||||
|
proc selvis_monitor { name args } {
|
||||||
|
global selectvisual viewvallabs
|
||||||
|
.bubar.selviewmenu invoke $viewvallabs($selectvisual)
|
||||||
|
}
|
||||||
|
# set selectvisual solution
|
||||||
|
|
||||||
|
|
||||||
#####################################################
|
#####################################################
|
||||||
@ -922,18 +939,19 @@ pack .bubar.center .bubar.zoomall .bubar.selview -side right
|
|||||||
label .helpline -text "None"
|
label .helpline -text "None"
|
||||||
pack forget .helpline -side bottom -fill x
|
pack forget .helpline -side bottom -fill x
|
||||||
|
|
||||||
frame .statbar -relief flat -bd 2
|
ttk::frame .statbar -relief flat
|
||||||
|
# -bd 2
|
||||||
pack .statbar -side bottom -fill x
|
pack .statbar -side bottom -fill x
|
||||||
|
|
||||||
label .statbar.ptslabel -text "Points: "
|
ttk::label .statbar.ptslabel -text "Points: "
|
||||||
label .statbar.ptsval -textvariable status_np
|
ttk::label .statbar.ptsval -textvariable status_np
|
||||||
label .statbar.elslabel -text " Elements: "
|
ttk::label .statbar.elslabel -text " Elements: "
|
||||||
label .statbar.elsval -textvariable status_ne
|
ttk::label .statbar.elsval -textvariable status_ne
|
||||||
label .statbar.selslabel -text " Surf Elements: "
|
ttk::label .statbar.selslabel -text " Surf Elements: "
|
||||||
label .statbar.selsval -textvariable status_nse
|
ttk::label .statbar.selsval -textvariable status_nse
|
||||||
# label .statbar.memlabel -text " Mem: "
|
# label .statbar.memlabel -text " Mem: "
|
||||||
# label .statbar.memval -textvariable mem_moveable
|
# label .statbar.memval -textvariable mem_moveable
|
||||||
label .statbar.task -textvariable status_task
|
ttk::label .statbar.task -textvariable status_task
|
||||||
|
|
||||||
pack .statbar.ptslabel .statbar.ptsval -side left -ipady 3p
|
pack .statbar.ptslabel .statbar.ptsval -side left -ipady 3p
|
||||||
pack .statbar.elslabel .statbar.elsval -side left -ipady 3p
|
pack .statbar.elslabel .statbar.elsval -side left -ipady 3p
|
||||||
|
30
ng/ng.tcl
30
ng/ng.tcl
@ -1,16 +1,25 @@
|
|||||||
|
lappend auto_path $env(NETGENDIR)
|
||||||
|
|
||||||
set batchmode [Ng_GetCommandLineParameter batchmode]
|
set batchmode [Ng_GetCommandLineParameter batchmode]
|
||||||
if {$batchmode=="undefined"} {
|
if {$batchmode=="undefined"} {
|
||||||
if {[catch {package require Tix } result ]} {
|
if {[catch {package require Tix } result ]} {
|
||||||
puts "cannot load package Tix"
|
puts "cannot load package Tix"
|
||||||
puts "error : $result"
|
puts "error : $result"
|
||||||
}
|
}
|
||||||
|
if {[catch {package require tkdnd } result ]} {
|
||||||
|
# puts "cannot load package tkdnd"
|
||||||
|
# puts "error : $result"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
# if {[catch {package require Togl 2.0 } result ]} {
|
# if {[catch {package require Togl 2.0 } result ]} {
|
||||||
# puts "cannot load package Togl 2.0"
|
# puts "cannot load package Togl 2.0"
|
||||||
# puts "error : $result"
|
# puts "error : $result"
|
||||||
# }
|
# }
|
||||||
|
|
||||||
|
# load [file dirname [info script]]/gears[info sharedlibextension]
|
||||||
|
# puts "load togl lib"
|
||||||
|
# load /Users/joachim/tcl_native3/Togl2.1/libTogl2.1.dylib
|
||||||
|
# puts "have togl lib"
|
||||||
# if {[catch {package require Togl 2.0 } result ]} {
|
# if {[catch {package require Togl 2.0 } result ]} {
|
||||||
# puts "cannot load package Togl 2.0"
|
# puts "cannot load package Togl 2.0"
|
||||||
# puts "error : $result"
|
# puts "error : $result"
|
||||||
@ -66,7 +75,7 @@ if { $batchmode != "defined" } {
|
|||||||
wm withdraw .
|
wm withdraw .
|
||||||
|
|
||||||
wm title . $progname
|
wm title . $progname
|
||||||
wm geometry . =800x600
|
wm geometry . =850x600
|
||||||
wm minsize . 400 300
|
wm minsize . 400 300
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,16 +84,15 @@ if { $batchmode != "defined" } {
|
|||||||
source ${ngdir}/variables.tcl
|
source ${ngdir}/variables.tcl
|
||||||
source ${ngdir}/parameters.tcl
|
source ${ngdir}/parameters.tcl
|
||||||
|
|
||||||
|
|
||||||
if { $batchmode != "defined" } {
|
if { $batchmode != "defined" } {
|
||||||
catch {
|
# catch {
|
||||||
source ${ngdir}/menustat.tcl
|
source ${ngdir}/menustat.tcl
|
||||||
}
|
# }
|
||||||
}
|
}
|
||||||
|
|
||||||
catch {
|
# catch {
|
||||||
source ${ngdir}/dialog.tcl
|
source ${ngdir}/dialog.tcl
|
||||||
}
|
# }
|
||||||
|
|
||||||
catch {
|
catch {
|
||||||
source ${ngdir}/drawing.tcl
|
source ${ngdir}/drawing.tcl
|
||||||
|
82
ng/ngpkg.cpp
82
ng/ngpkg.cpp
@ -24,8 +24,12 @@ The interface between the GUI and the netgen library
|
|||||||
|
|
||||||
|
|
||||||
// to be sure to include the 'right' togl-version
|
// to be sure to include the 'right' togl-version
|
||||||
|
#ifdef USE_TOGL_2
|
||||||
|
#include "Togl2.1/togl.h"
|
||||||
|
#else // USE_TOGL_2
|
||||||
#include "togl_1_7.h"
|
#include "togl_1_7.h"
|
||||||
// #include "togl_2_0.h"
|
#endif // USE_TOGL_2
|
||||||
|
#include "fonts.hpp"
|
||||||
|
|
||||||
extern bool nodisplay;
|
extern bool nodisplay;
|
||||||
|
|
||||||
@ -1318,28 +1322,15 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
/*
|
if (ng_geometry)
|
||||||
if (geometry2d)
|
|
||||||
{
|
{
|
||||||
extern void MeshFromSpline2D (SplineGeometry2d & geometry2d,
|
|
||||||
Mesh *& mesh, MeshingParameters & mp);
|
|
||||||
MeshFromSpline2D (*geometry2d, mesh.Ptr(), mparam);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
Mesh * hmesh = NULL;
|
|
||||||
int res = ng_geometry -> GenerateMesh (hmesh, mparam, perfstepsstart, perfstepsend);
|
|
||||||
mesh = shared_ptr<Mesh> (hmesh);
|
|
||||||
*/
|
|
||||||
mesh = make_shared<Mesh> ();
|
mesh = make_shared<Mesh> ();
|
||||||
// vsmesh.SetMesh (mesh);
|
// vsmesh.SetMesh (mesh);
|
||||||
SetGlobalMesh (mesh);
|
SetGlobalMesh (mesh);
|
||||||
mesh -> SetGeometry(ng_geometry);
|
mesh -> SetGeometry(ng_geometry);
|
||||||
|
|
||||||
int res = ng_geometry -> GenerateMesh (mesh, mparam, perfstepsstart, perfstepsend);
|
int res = ng_geometry -> GenerateMesh (mesh, mparam, perfstepsstart, perfstepsend);
|
||||||
|
|
||||||
// int res = ng_geometry -> GenerateMesh (mesh.Ptr(), mparam, perfstepsstart, perfstepsend);
|
|
||||||
if (res != MESHING3_OK)
|
if (res != MESHING3_OK)
|
||||||
{
|
{
|
||||||
multithread.task = savetask;
|
multithread.task = savetask;
|
||||||
@ -1347,6 +1338,14 @@ namespace netgen
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else // no ng_geometry
|
||||||
|
{
|
||||||
|
multithread.task = savetask;
|
||||||
|
multithread.running = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (mparam.autozrefine)
|
if (mparam.autozrefine)
|
||||||
{
|
{
|
||||||
@ -1928,7 +1927,12 @@ namespace netgen
|
|||||||
glCallLists (GLsizei(strlen(text)), GL_UNSIGNED_BYTE, text);
|
glCallLists (GLsizei(strlen(text)), GL_UNSIGNED_BYTE, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
Ng_ToglVersion(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
Tcl_SetResult (interp, (char*)"1", TCL_STATIC);
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static void init( struct Togl *togl )
|
static void init( struct Togl *togl )
|
||||||
{
|
{
|
||||||
@ -2047,30 +2051,33 @@ namespace netgen
|
|||||||
|
|
||||||
// Sorry, Togl 2.0 not supported
|
// Sorry, Togl 2.0 not supported
|
||||||
|
|
||||||
Tcl_Obj * togl_font;
|
Font * font = nullptr;
|
||||||
Togl * togl = NULL;
|
Togl * togl = NULL;
|
||||||
|
|
||||||
void MyOpenGLText (const char * text)
|
void MyOpenGLText_GUI (const char * text)
|
||||||
{
|
{
|
||||||
// cout << "togl - text: " << text << endl;
|
glListBase (font->getDisplayListsBase());
|
||||||
Togl_WriteChars (togl, togl_font, text, strlen(text));
|
glCallLists (GLsizei(strlen(text)), GL_UNSIGNED_BYTE, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
Ng_ToglVersion(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
|
||||||
|
{
|
||||||
|
Tcl_SetResult (interp, (char*)"2", TCL_STATIC);
|
||||||
|
return TCL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
init(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
|
init(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
|
||||||
{
|
{
|
||||||
cout << "call init" << endl;
|
// cout << "call init" << endl;
|
||||||
|
|
||||||
|
|
||||||
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK)
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK)
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
|
|
||||||
cout << "call Togl - load font (crashes on my OpenSuse Linux64)" << endl;
|
// possible values: 12,14,16,18,20,22,24,28,32
|
||||||
// togl_font = Togl_LoadBitmapFont( togl, "Helvetica");
|
font = selectFont(18);
|
||||||
// togl_font = Togl_LoadBitmapFont( togl, "Times");
|
|
||||||
// togl_font = Togl_LoadBitmapFont( togl, TOGL_BITMAP_8_BY_13 );
|
|
||||||
togl_font = Togl_LoadBitmapFont( togl, NULL );
|
|
||||||
cout << "success" << endl;
|
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
@ -2078,6 +2085,7 @@ namespace netgen
|
|||||||
|
|
||||||
SetVisualScene (Togl_Interp(togl));
|
SetVisualScene (Togl_Interp(togl));
|
||||||
vs->DrawScene();
|
vs->DrawScene();
|
||||||
|
Set_OpenGLText_Callback (&MyOpenGLText_GUI);
|
||||||
return TCL_OK;
|
return TCL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2110,7 +2118,21 @@ namespace netgen
|
|||||||
int w = Togl_Width (togl);
|
int w = Togl_Width (togl);
|
||||||
int h = Togl_Height (togl);
|
int h = Togl_Height (togl);
|
||||||
|
|
||||||
glViewport(0, 0, w, h);
|
// glViewport(0, 0, w, h);
|
||||||
|
int res[4];
|
||||||
|
glGetIntegerv(GL_VIEWPORT, res);
|
||||||
|
// cout << "w = " << w << " h = " << h << endl;
|
||||||
|
w = res[2];
|
||||||
|
h = res[3];
|
||||||
|
/*
|
||||||
|
cout << "viewport: "
|
||||||
|
<< res[0] << " "
|
||||||
|
<< res[1] << " "
|
||||||
|
<< res[2] << " "
|
||||||
|
<< res[3] << endl;
|
||||||
|
*/
|
||||||
|
// change font size according to window width
|
||||||
|
font = selectFont(w/80);
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
@ -3453,6 +3475,8 @@ void PlayAnimFile(const char* name, int speed, int maxcnt)
|
|||||||
* Specify the C callback functions for widget creation, display,
|
* Specify the C callback functions for widget creation, display,
|
||||||
* and reshape.
|
* and reshape.
|
||||||
*/
|
*/
|
||||||
|
Tcl_CreateObjCommand(interp, "Ng_GetToglVersion", Ng_ToglVersion, NULL, NULL);
|
||||||
|
|
||||||
#if TOGL_MAJOR_VERSION==1
|
#if TOGL_MAJOR_VERSION==1
|
||||||
if (!nodisplay)
|
if (!nodisplay)
|
||||||
{
|
{
|
||||||
|
293
ng/ngvisual.tcl
293
ng/ngvisual.tcl
@ -345,12 +345,12 @@ proc lineplotdialog { } {
|
|||||||
|
|
||||||
pack $w.filesettings -fill x -ipady 3
|
pack $w.filesettings -fill x -ipady 3
|
||||||
|
|
||||||
frame $w.settings -relief groove -borderwidth 3
|
ttk::frame $w.settings -relief groove -borderwidth 3
|
||||||
label $w.settings.title -text "\nSettings\n"
|
ttk::label $w.settings.title -text "\nSettings\n"
|
||||||
pack $w.settings.title
|
pack $w.settings.title
|
||||||
|
|
||||||
frame $w.settings.minmax
|
ttk::frame $w.settings.minmax
|
||||||
checkbutton $w.settings.minmax.autoscale -text "Autoscale" -variable visoptions.lineplotautoscale
|
ttk::checkbutton $w.settings.minmax.autoscale -text "Autoscale" -variable visoptions.lineplotautoscale
|
||||||
tixControl $w.settings.minmax.xmin -label "Min. x: " \
|
tixControl $w.settings.minmax.xmin -label "Min. x: " \
|
||||||
-integer false -variable visoptions.lineplotxmin \
|
-integer false -variable visoptions.lineplotxmin \
|
||||||
-options {
|
-options {
|
||||||
@ -981,7 +981,6 @@ proc visual_dialog { } {
|
|||||||
|
|
||||||
set w .visoptions_dlg
|
set w .visoptions_dlg
|
||||||
|
|
||||||
|
|
||||||
global visual_dialog_pop1
|
global visual_dialog_pop1
|
||||||
global visual_dialog_pop2
|
global visual_dialog_pop2
|
||||||
global visual_dialog_pop3
|
global visual_dialog_pop3
|
||||||
@ -1003,10 +1002,7 @@ proc visual_dialog { } {
|
|||||||
focus $w
|
focus $w
|
||||||
} {
|
} {
|
||||||
|
|
||||||
toplevel $w
|
toplevel $w
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
frame $w.grid -relief groove -borderwidth 3
|
frame $w.grid -relief groove -borderwidth 3
|
||||||
@ -1016,7 +1012,7 @@ proc visual_dialog { } {
|
|||||||
-resolution 1 \
|
-resolution 1 \
|
||||||
-variable visoptions.gridsize \
|
-variable visoptions.gridsize \
|
||||||
-command { popupcheckredraw visual_dialog_pop2 }
|
-command { popupcheckredraw visual_dialog_pop2 }
|
||||||
|
|
||||||
|
|
||||||
# x- and y- offset
|
# x- and y- offset
|
||||||
scale $w.grid.xoffset -orient horizontal -length 80 -from 0 -to 1 \
|
scale $w.grid.xoffset -orient horizontal -length 80 -from 0 -to 1 \
|
||||||
@ -1042,27 +1038,32 @@ proc visual_dialog { } {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
frame $w.deform -relief groove -borderwidth 3
|
ttk::frame $w.deform -relief groove -borderwidth 3
|
||||||
checkbutton $w.deform.cb -text "Deformation" \
|
ttk::checkbutton $w.deform.cb -text "Deformation" \
|
||||||
-variable visoptions.deformation \
|
-variable visoptions.deformation \
|
||||||
-command { Ng_Vis_Set parameters; redraw }
|
-command { Ng_Vis_Set parameters; redraw }
|
||||||
|
|
||||||
tixControl $w.deform.sc1 -label "Scale: " -integer false \
|
ttk::label $w.deform.l -text "Scale: "
|
||||||
-variable visoptions.scaledeform1 \
|
ttk::spinbox $w.deform.sc1 -from 0 -to 1e99 -textvariable visoptions.scaledeform1 -width 5 \
|
||||||
-command { Ng_Vis_Set parameters; redraw } \
|
-command { Ng_Vis_Set parameters; redraw } \
|
||||||
-options {
|
-validate focusout -validatecommand { Ng_Vis_Set parameters; redraw; string is double %P } \
|
||||||
entry.width 6
|
-invalidcommand { puts "invalid value, %P %s"; set visoptions.scaledeform1 1; }
|
||||||
label.width 7
|
|
||||||
label.anchor e
|
# tixControl $w.deform.sc1 -label "Scale: " -integer false \
|
||||||
}
|
# -variable visoptions.scaledeform1 \
|
||||||
|
# -command { Ng_Vis_Set parameters; redraw } \
|
||||||
|
# -options {
|
||||||
|
# entry.width 6
|
||||||
|
# label.width 7
|
||||||
|
# label.anchor e
|
||||||
|
# }
|
||||||
|
|
||||||
scale $w.deform.sc2 -orient horizontal -length 100 -from 0 -to 1 \
|
ttk::scale $w.deform.sc2 -orient horizontal -length 100 -from 0 -to 1 \
|
||||||
-resolution 0.01 \
|
|
||||||
-variable visoptions.scaledeform2 \
|
-variable visoptions.scaledeform2 \
|
||||||
-command { popupcheckredraw visual_dialog_pop5 }
|
-command { popupcheckredraw visual_dialog_pop5 }
|
||||||
|
|
||||||
pack $w.deform -fill x -ipady 2
|
pack $w.deform -fill x -ipady 2
|
||||||
pack $w.deform.cb $w.deform.sc1 $w.deform.sc2 -side left -expand yes
|
pack $w.deform.cb $w.deform.l $w.deform.sc1 $w.deform.sc2 -side left -expand yes
|
||||||
|
|
||||||
|
|
||||||
frame $w.as -relief groove -borderwidth 3
|
frame $w.as -relief groove -borderwidth 3
|
||||||
@ -1093,31 +1094,30 @@ proc visual_dialog { } {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
frame $w.iso -relief groove -borderwidth 3
|
ttk::frame $w.iso -relief groove -borderwidth 3
|
||||||
pack $w.iso -fill x -ipady 3
|
pack $w.iso -fill x -ipady 3
|
||||||
|
|
||||||
frame $w.iso.cb
|
ttk::frame $w.iso.cb
|
||||||
pack $w.iso.cb -side left
|
pack $w.iso.cb -side left
|
||||||
|
|
||||||
checkbutton $w.iso.cb.isolines -text "Iso-lines" \
|
ttk::checkbutton $w.iso.cb.isolines -text "Iso-lines" \
|
||||||
-variable visoptions.isolines \
|
-variable visoptions.isolines \
|
||||||
-command { Ng_Vis_Set parameters; redraw }
|
-command { Ng_Vis_Set parameters; redraw }
|
||||||
pack $w.iso.cb.isolines -side top
|
pack $w.iso.cb.isolines -side top -anchor w
|
||||||
|
|
||||||
checkbutton $w.iso.cb.isosurf -text "Iso-Surface" \
|
ttk::checkbutton $w.iso.cb.isosurf -text "Iso-Surface" \
|
||||||
-variable visoptions.isosurf \
|
-variable visoptions.isosurf \
|
||||||
-command { Ng_Vis_Set parameters; redraw }
|
-command { Ng_Vis_Set parameters; redraw }
|
||||||
pack $w.iso.cb.isosurf -side top
|
pack $w.iso.cb.isosurf -side top -anchor w
|
||||||
|
|
||||||
|
|
||||||
|
ttk::scale $w.iso.numiso -orient horizontal -length 100 -from 2 -to 50 \
|
||||||
scale $w.iso.numiso -orient horizontal -length 100 -from 2 -to 50 \
|
|
||||||
-label "" \
|
|
||||||
-resolution 1 \
|
|
||||||
-variable visoptions.numiso \
|
-variable visoptions.numiso \
|
||||||
-command { popupcheckredraw visual_dialog_pop6 }
|
-command { popupcheckredraw visual_dialog_pop6 }
|
||||||
|
# -resolution 1 \
|
||||||
|
# -label "" \
|
||||||
|
|
||||||
pack $w.iso.numiso -side left
|
pack $w.iso.numiso -side left -anchor n
|
||||||
|
|
||||||
|
|
||||||
# scale $w.iso.subdiv -orient horizontal -length 100 -from 0 -to 5 \
|
# scale $w.iso.subdiv -orient horizontal -length 100 -from 0 -to 5 \
|
||||||
@ -1127,39 +1127,39 @@ proc visual_dialog { } {
|
|||||||
# -command { popupcheckredraw visual_dialog_pop7 }
|
# -command { popupcheckredraw visual_dialog_pop7 }
|
||||||
# # -command { puts "subdiv-vis"; Ng_Vis_Set parameters; puts "cal redraw"; redraw }
|
# # -command { puts "subdiv-vis"; Ng_Vis_Set parameters; puts "cal redraw"; redraw }
|
||||||
|
|
||||||
frame $w.iso.subdiv
|
ttk::frame $w.iso.subdiv
|
||||||
radiobutton $w.iso.subdiv.zero -text "0" -variable visoptions.subdivisions -value 0 \
|
ttk::radiobutton $w.iso.subdiv.zero -text "0" -variable visoptions.subdivisions -value 0 \
|
||||||
-command {
|
-command {
|
||||||
#set visoptions.subdivisions 1;
|
#set visoptions.subdivisions 1;
|
||||||
Ng_Vis_Set parameters; redraw;
|
Ng_Vis_Set parameters; redraw;
|
||||||
}
|
}
|
||||||
radiobutton $w.iso.subdiv.one -text "1" -variable visoptions.subdivisions -value 1 \
|
ttk::radiobutton $w.iso.subdiv.one -text "1" -variable visoptions.subdivisions -value 1 \
|
||||||
-command {
|
-command {
|
||||||
#set visoptions.subdivisions 1;
|
#set visoptions.subdivisions 1;
|
||||||
Ng_Vis_Set parameters; redraw;
|
Ng_Vis_Set parameters; redraw;
|
||||||
}
|
}
|
||||||
radiobutton $w.iso.subdiv.two -text "2" -variable visoptions.subdivisions -value 2 \
|
ttk::radiobutton $w.iso.subdiv.two -text "2" -variable visoptions.subdivisions -value 2 \
|
||||||
-command {
|
-command {
|
||||||
#set visoptions.subdivisions 2;
|
#set visoptions.subdivisions 2;
|
||||||
Ng_Vis_Set parameters; redraw;
|
Ng_Vis_Set parameters; redraw;
|
||||||
}
|
}
|
||||||
radiobutton $w.iso.subdiv.three -text "3" -variable visoptions.subdivisions -value 3 \
|
ttk::radiobutton $w.iso.subdiv.three -text "3" -variable visoptions.subdivisions -value 3 \
|
||||||
-command {
|
-command {
|
||||||
#set visoptions.subdivisions 3;
|
#set visoptions.subdivisions 3;
|
||||||
Ng_Vis_Set parameters; redraw;
|
Ng_Vis_Set parameters; redraw;
|
||||||
}
|
}
|
||||||
radiobutton $w.iso.subdiv.four -text "4" -variable visoptions.subdivisions -value 4 \
|
ttk::radiobutton $w.iso.subdiv.four -text "4" -variable visoptions.subdivisions -value 4 \
|
||||||
-command {
|
-command {
|
||||||
#set visoptions.subdivisions 4;
|
#set visoptions.subdivisions 4;
|
||||||
Ng_Vis_Set parameters; redraw;
|
Ng_Vis_Set parameters; redraw;
|
||||||
}
|
}
|
||||||
radiobutton $w.iso.subdiv.five -text "5" -variable visoptions.subdivisions -value 5 \
|
ttk::radiobutton $w.iso.subdiv.five -text "5" -variable visoptions.subdivisions -value 5 \
|
||||||
-command {
|
-command {
|
||||||
#set visoptions.subdivisions 5;
|
#set visoptions.subdivisions 5;
|
||||||
Ng_Vis_Set parameters; redraw;
|
Ng_Vis_Set parameters; redraw;
|
||||||
}
|
}
|
||||||
|
|
||||||
label $w.iso.subdiv.text -text "subdivision"
|
ttk::label $w.iso.subdiv.text -text "subdivision"
|
||||||
|
|
||||||
pack $w.iso.subdiv -side right -ipadx 10
|
pack $w.iso.subdiv -side right -ipadx 10
|
||||||
|
|
||||||
@ -1184,18 +1184,18 @@ proc visual_dialog { } {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
frame $w.redraw -relief groove -borderwidth 3
|
ttk::frame $w.redraw -relief groove -borderwidth 3
|
||||||
checkbutton $w.redraw.auto -text "Auto-redraw" \
|
ttk::checkbutton $w.redraw.auto -text "Auto-redraw after (sec)" \
|
||||||
-variable visoptions.autoredraw
|
-variable visoptions.autoredraw
|
||||||
|
|
||||||
tixControl $w.redraw.val -label " after (sec) " -integer false \
|
# tixControl $w.redraw.val -integer false \
|
||||||
-variable visoptions.autoredrawtime \
|
# -variable visoptions.autoredrawtime \
|
||||||
-options {
|
# -options {
|
||||||
entry.width 6
|
# entry.width 6
|
||||||
label.width 0
|
# label.width 0
|
||||||
label.anchor w
|
# label.anchor w
|
||||||
}
|
# }
|
||||||
|
ttk::spinbox $w.redraw.val -textvariable visoptions.autoredrawtime -from 0 -to 100 -width 3
|
||||||
pack $w.redraw -fill x -ipady 3
|
pack $w.redraw -fill x -ipady 3
|
||||||
pack $w.redraw.auto $w.redraw.val -side left
|
pack $w.redraw.auto $w.redraw.val -side left
|
||||||
|
|
||||||
@ -1212,19 +1212,129 @@ proc visual_dialog { } {
|
|||||||
label.width 0
|
label.width 0
|
||||||
label.anchor w
|
label.anchor w
|
||||||
}
|
}
|
||||||
pack $w.redraw.simtime -side left
|
# pack $w.redraw.simtime -side left
|
||||||
|
|
||||||
|
pack [ttk::frame $w.f] -fill x
|
||||||
|
pack [ttk::frame $w.f.f1] -expand yes
|
||||||
|
set f [ttk::frame $w.f.f1.clipsol]
|
||||||
|
pack $f -anchor e
|
||||||
|
menu $f.m
|
||||||
|
ttk::menubutton $f.b -menu $f.m -width 12
|
||||||
|
ttk::label $f.l -text "Clipping Plane Sol: "
|
||||||
|
|
||||||
|
global visoptions.clipsolution
|
||||||
|
set clipsollabs(none) "None"
|
||||||
|
set clipsollabs(scal) "Scalar Function"
|
||||||
|
set clipsollabs(vec) "Vector Function"
|
||||||
|
foreach i { none scal vec } {
|
||||||
|
set textval $clipsollabs($i)
|
||||||
|
$f.m add command -label "$textval" -command \
|
||||||
|
"$f.b configure -text \"$textval\" ; set visoptions.clipsolution $i ; "
|
||||||
|
}
|
||||||
|
|
||||||
|
pack $f.b $f.l -side right
|
||||||
|
$f.m invoke $clipsollabs(${visoptions.clipsolution})
|
||||||
|
|
||||||
|
|
||||||
|
# pack [ttk::frame $w.f1.scalfun] -anchor e
|
||||||
|
set f [ttk::frame $w.f.f1.scalfun]
|
||||||
|
pack $f -anchor e
|
||||||
|
menu $f.m
|
||||||
|
ttk::menubutton $f.b -menu $f.m -width 12
|
||||||
|
ttk::label $f.l -text "Scalar Function: "
|
||||||
|
set scalentries [list none None]
|
||||||
|
|
||||||
|
for { set i 1 } { $i <= [Ng_Vis_Field getnfieldnames] } { incr i } {
|
||||||
|
set fname [Ng_Vis_Field getfieldname $i]
|
||||||
|
set fcomp [Ng_Vis_Field getfieldcomponents $i]
|
||||||
|
if { $fcomp == 1 } {
|
||||||
|
lappend scalentries $fname:1 $fname
|
||||||
|
} {
|
||||||
|
for { set j 1 } { $j <= $fcomp } { incr j } {
|
||||||
|
lappend scalentries $fname:$j "$fname ($j)"
|
||||||
|
}
|
||||||
|
lappend scalentries $fname:0 "func ($fname)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
global visoptions.scalfunction
|
||||||
|
foreach { name textval } $scalentries {
|
||||||
|
$f.m add command -label "$textval" -command \
|
||||||
|
"$f.b configure -text \"$textval\" ; set visoptions.scalfunction $name ; Ng_Vis_Set parameters ; redraw ; "
|
||||||
|
}
|
||||||
|
|
||||||
|
pack $f.b $f.l -side right
|
||||||
|
foreach { name textval } $scalentries {
|
||||||
|
if { ${visoptions.scalfunction} == $name } {
|
||||||
|
$f.m invoke $textval
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
set f [ttk::frame $w.f.f1.vecfun]
|
||||||
|
pack $f -anchor e
|
||||||
|
menu $f.m
|
||||||
|
ttk::menubutton $f.b -menu $f.m -width 12
|
||||||
|
ttk::label $f.l -text "Vector Function: "
|
||||||
|
set vecentries [list none None]
|
||||||
|
|
||||||
|
for { set i 1 } { $i <= [Ng_Vis_Field getnfieldnames] } { incr i } {
|
||||||
|
set fname [Ng_Vis_Field getfieldname $i]
|
||||||
|
set fcomp [Ng_Vis_Field getfieldcomponents $i]
|
||||||
|
set iscomplex [Ng_Vis_Field iscomplex $i]
|
||||||
|
set sdim [Ng_Vis_Field getdimension]
|
||||||
|
if { $iscomplex == 1 } { set fcomp [expr $fcomp / 2] }
|
||||||
|
if { ($fcomp == $sdim) || ($fcomp == 3) } {
|
||||||
|
lappend vecentries $fname $fname
|
||||||
|
}
|
||||||
|
}
|
||||||
|
global visoptions.vecfunction
|
||||||
|
foreach { name textval } $vecentries {
|
||||||
|
$f.m add command -label "$textval" -command \
|
||||||
|
"$f.b configure -text \"$textval\" ; set visoptions.vecfunction $name ; Ng_Vis_Set parameters ; redraw ; "
|
||||||
|
}
|
||||||
|
|
||||||
|
pack $f.b $f.l -side right
|
||||||
|
foreach { name textval } $vecentries {
|
||||||
|
if { ${visoptions.vecfunction} == $name } {
|
||||||
|
$f.m invoke $textval
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
set f [ttk::frame $w.f.f1.evaluate]
|
||||||
|
pack $f -anchor e
|
||||||
|
|
||||||
|
menu $f.m
|
||||||
|
ttk::menubutton $f.b -menu $f.m -width 12
|
||||||
|
ttk::label $f.l -text "Evaluate: "
|
||||||
|
|
||||||
|
global visoptions.evaluate
|
||||||
|
set evallabs(abs) "| |"
|
||||||
|
set evallabs(abstens) "|tensor|"
|
||||||
|
set evallabs(mises) "Mises"
|
||||||
|
set evallabs(main) "Main"
|
||||||
|
foreach i { abs abstens mises main } {
|
||||||
|
set textval $evallabs($i)
|
||||||
|
$f.m add command -label "$textval" -command \
|
||||||
|
"$f.b configure -text \"$textval\" ; set visoptions.evaluate $i ; "
|
||||||
|
}
|
||||||
|
pack $f.b $f.l -side right
|
||||||
|
$f.m invoke $evallabs(${visoptions.evaluate})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
tixOptionMenu $w.clipsol -label "Clipping Plane Sol: " \
|
tixOptionMenu $w.clipsol -label "Clipping Plane Sol: " \
|
||||||
-options {
|
-options {
|
||||||
label.width 18
|
label.width 18
|
||||||
label.anchor e
|
label.anchor e
|
||||||
menubutton.width 12
|
menubutton.width 12
|
||||||
}
|
}
|
||||||
|
|
||||||
set none 1
|
|
||||||
$w.clipsol add command none -label None
|
$w.clipsol add command none -label None
|
||||||
$w.clipsol add command scal -label "Scalar Function"
|
$w.clipsol add command scal -label "Scalar Function"
|
||||||
$w.clipsol add command vec -label "Vector Function"
|
$w.clipsol add command vec -label "Vector Function"
|
||||||
@ -1232,8 +1342,7 @@ proc visual_dialog { } {
|
|||||||
$w.clipsol configure -variable visoptions.clipsolution
|
$w.clipsol configure -variable visoptions.clipsolution
|
||||||
$w.clipsol configure -command { Ng_Vis_Set parameters; redraw }
|
$w.clipsol configure -command { Ng_Vis_Set parameters; redraw }
|
||||||
|
|
||||||
pack $w.clipsol
|
# pack $w.clipsol
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1300,8 +1409,18 @@ proc visual_dialog { } {
|
|||||||
redraw
|
redraw
|
||||||
}
|
}
|
||||||
|
|
||||||
pack $w.scalfun $w.vecfun $w.evaluate
|
# pack $w.scalfun $w.vecfun $w.evaluate
|
||||||
|
|
||||||
|
pack [ttk::frame $w.multidim] -fill x
|
||||||
|
set f [ttk::frame $w.multidim.f]
|
||||||
|
pack $f
|
||||||
|
ttk::label $f.l1 -text "multidim-component: "
|
||||||
|
ttk::spinbox $f.sb1 -from 0 -to 1e99 -textvariable visoptions.multidimcomponent -width 3 \
|
||||||
|
-command { Ng_Vis_Set parameters; redraw }
|
||||||
|
pack $f.l1 $f.sb1 -side left
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
tixControl $w.multidimcomp -label "multidim-component: " -integer true \
|
tixControl $w.multidimcomp -label "multidim-component: " -integer true \
|
||||||
-variable visoptions.multidimcomponent -min 0 \
|
-variable visoptions.multidimcomponent -min 0 \
|
||||||
-command { Ng_Vis_Set parameters; redraw } \
|
-command { Ng_Vis_Set parameters; redraw } \
|
||||||
@ -1310,44 +1429,44 @@ proc visual_dialog { } {
|
|||||||
label.width 18
|
label.width 18
|
||||||
label.anchor e
|
label.anchor e
|
||||||
}
|
}
|
||||||
|
# pack $w.multidimcomp
|
||||||
|
|
||||||
pack $w.multidimcomp
|
pack [ttk::frame $w.fcb] -fill x
|
||||||
|
ttk::frame $w.fcb.cb
|
||||||
|
pack $w.fcb.cb
|
||||||
checkbutton $w.showsurfsolution -text "Draw Surface Vectors" \
|
|
||||||
|
ttk::checkbutton $w.fcb.cb.showsurfsolution -text "Draw Surface Vectors" \
|
||||||
-variable visoptions.showsurfacesolution \
|
-variable visoptions.showsurfacesolution \
|
||||||
-command { Ng_Vis_Set parameters; redraw }
|
-command { Ng_Vis_Set parameters; redraw }
|
||||||
|
|
||||||
checkbutton $w.showcurves -text "Show Curves" \
|
ttk::checkbutton $w.fcb.cb.showcurves -text "Show Curves" \
|
||||||
-variable visoptions.drawpointcurves \
|
-variable visoptions.drawpointcurves \
|
||||||
-command { Ng_Vis_Set parameters; redraw }
|
-command { Ng_Vis_Set parameters; redraw }
|
||||||
|
|
||||||
checkbutton $w.imaginary -text "Imaginary Part" \
|
ttk::checkbutton $w.fcb.cb.imaginary -text "Imaginary Part" \
|
||||||
-variable visoptions.imaginary \
|
-variable visoptions.imaginary \
|
||||||
-command { Ng_Vis_Set parameters; redraw }
|
-command { Ng_Vis_Set parameters; redraw }
|
||||||
|
|
||||||
checkbutton $w.logscale -text "Log Scale" \
|
ttk::checkbutton $w.fcb.cb.logscale -text "Log Scale" \
|
||||||
-variable visoptions.logscale \
|
-variable visoptions.logscale \
|
||||||
-command { Ng_Vis_Set parameters; redraw }
|
-command { Ng_Vis_Set parameters; redraw }
|
||||||
|
|
||||||
checkbutton $w.invcolor -text "Inverse Color" \
|
ttk::checkbutton $w.fcb.cb.invcolor -text "Inverse Color" \
|
||||||
-variable visoptions.invcolor \
|
-variable visoptions.invcolor \
|
||||||
-command { Ng_Vis_Set parametersrange; redraw }
|
-command { Ng_Vis_Set parametersrange; redraw }
|
||||||
|
|
||||||
|
|
||||||
frame $w.texframe
|
ttk::frame $w.fcb.cb.texframe
|
||||||
|
|
||||||
checkbutton $w.texframe.usetexture -text "Use Textures (" \
|
ttk::checkbutton $w.fcb.cb.texframe.usetexture -text "Use Textures (" \
|
||||||
-variable visoptions.usetexture \
|
-variable visoptions.usetexture \
|
||||||
-command { Ng_Vis_Set parameters; redraw }
|
-command { Ng_Vis_Set parameters; redraw }
|
||||||
|
|
||||||
checkbutton $w.texframe.lintexture -text "Linear )" \
|
ttk::checkbutton $w.fcb.cb.texframe.lintexture -text "Linear )" \
|
||||||
-variable visoptions.lineartexture \
|
-variable visoptions.lineartexture \
|
||||||
-command { Ng_Vis_Set parametersrange; redraw }
|
-command { Ng_Vis_Set parametersrange; redraw }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
checkbutton $w.lineartexture -text "Use Linear Texture" \
|
ttk::checkbutton $w.fcb.cb.lineartexture -text "Use Linear Texture" \
|
||||||
-variable visoptions.lineartexture \
|
-variable visoptions.lineartexture \
|
||||||
-command { Ng_Vis_Set parameters; redraw }
|
-command { Ng_Vis_Set parameters; redraw }
|
||||||
|
|
||||||
@ -1356,12 +1475,12 @@ proc visual_dialog { } {
|
|||||||
-variable visoptions.numtexturecols \
|
-variable visoptions.numtexturecols \
|
||||||
-command { popupcheckredraw visual_dialog_pop1 }
|
-command { popupcheckredraw visual_dialog_pop1 }
|
||||||
|
|
||||||
checkbutton $w.showclipsolution -text "Draw Clipping Plane Solution" \
|
ttk::checkbutton $w.fcb.cb.showclipsolution -text "Draw Clipping Plane Solution" \
|
||||||
-variable visoptions.showclipsolution \
|
-variable visoptions.showclipsolution \
|
||||||
-command { Ng_Vis_Set parameters; redraw }
|
-command { Ng_Vis_Set parameters; redraw }
|
||||||
|
|
||||||
|
|
||||||
checkbutton $w.redrawperiodic -text "Animate periodic" \
|
ttk::checkbutton $w.fcb.cb.redrawperiodic -text "Animate periodic" \
|
||||||
-variable visoptions.redrawperiodic \
|
-variable visoptions.redrawperiodic \
|
||||||
-command {
|
-command {
|
||||||
redrawperiodic
|
redrawperiodic
|
||||||
@ -1369,38 +1488,38 @@ proc visual_dialog { } {
|
|||||||
redraw
|
redraw
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pack $w.fcb.cb.showsurfsolution $w.fcb.cb.showcurves -anchor w
|
||||||
pack $w.showsurfsolution $w.showcurves
|
pack $w.fcb.cb.imaginary $w.fcb.cb.logscale $w.fcb.cb.texframe $w.fcb.cb.invcolor $w.fcb.cb.redrawperiodic -side top -anchor w
|
||||||
pack $w.imaginary $w.logscale $w.texframe $w.invcolor $w.redrawperiodic
|
pack $w.fcb.cb.texframe.usetexture $w.fcb.cb.texframe.lintexture -side left -expand yes
|
||||||
pack $w.texframe.usetexture $w.texframe.lintexture -side left -expand yes
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
frame $w.bu
|
frame $w.fcb.bu -relief groove -borderwidth 3
|
||||||
pack $w.bu -pady 5
|
pack $w.fcb.bu -pady 5
|
||||||
|
|
||||||
button $w.bu.showsol -text "Show Solution" -command {
|
ttk::button $w.fcb.bu.showsol -text "Show Solution" -command {
|
||||||
set selectvisual solution
|
set selectvisual solution
|
||||||
Ng_SetVisParameters
|
Ng_SetVisParameters
|
||||||
redraw
|
redraw
|
||||||
}
|
}
|
||||||
button $w.bu.clipping -text "Clipping" -command {
|
ttk::button $w.fcb.bu.clipping -text "Clipping" -command {
|
||||||
clippingdialog;
|
clippingdialog;
|
||||||
}
|
}
|
||||||
button $w.bu.fieldlines -text "Fieldlines" -command {
|
ttk::button $w.fcb.bu.fieldlines -text "Fieldlines" -command {
|
||||||
fieldlinesdialog;
|
fieldlinesdialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
button $w.bu.lineplot -text "2D Lineplot" -command {
|
ttk::button $w.fcb.bu.lineplot -text "2D Lineplot" -command {
|
||||||
lineplotdialog;
|
lineplotdialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
button $w.bu.done -text "Close" -command {
|
ttk::button $w.fcb.bu.done -text "Close" -command {
|
||||||
destroy .visoptions_dlg
|
destroy .visoptions_dlg
|
||||||
}
|
}
|
||||||
|
|
||||||
pack $w.bu.showsol $w.bu.clipping $w.bu.fieldlines $w.bu.lineplot $w.bu.done -side left -expand yes
|
pack $w.fcb.bu.showsol $w.fcb.bu.clipping $w.fcb.bu.fieldlines $w.fcb.bu.lineplot $w.fcb.bu.done -side left -expand yes
|
||||||
|
|
||||||
|
|
||||||
wm withdraw $w
|
wm withdraw $w
|
||||||
wm geom $w +100+100
|
wm geom $w +100+100
|
||||||
|
@ -642,7 +642,7 @@ proc saveinifile { } {
|
|||||||
if {[catch { set datei [open $inifilename w] } result ]} {
|
if {[catch { set datei [open $inifilename w] } result ]} {
|
||||||
puts "cannot write file $inifilename"
|
puts "cannot write file $inifilename"
|
||||||
} {
|
} {
|
||||||
for { set i [.ngmenu.file.recent index last] } { $i >= 1 } { incr i -1 } {
|
for { set i [.ngmenu.file.recent index last] } { $i >= 0 } { incr i -1 } {
|
||||||
puts $datei "recentfile \"[.ngmenu.file.recent entrycget $i -label]\""
|
puts $datei "recentfile \"[.ngmenu.file.recent entrycget $i -label]\""
|
||||||
}
|
}
|
||||||
close $datei
|
close $datei
|
||||||
|
@ -24,7 +24,7 @@ if(NOT WIN32)
|
|||||||
target_link_libraries( nglib mesh stlvis stl geom2dvis interface geom2d csg stl visual csgvis )
|
target_link_libraries( nglib mesh stlvis stl geom2dvis interface geom2d csg stl visual csgvis )
|
||||||
endif(NOT WIN32)
|
endif(NOT WIN32)
|
||||||
|
|
||||||
target_link_libraries( nglib ${LIBPTHREAD} ${OCC_LIBRARIES} ${LIBTOGL} ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} ${TK_LIBRARY} ${TCL_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${X11_Xmu_LIB} ${JPEG_LIBRARIES} ${MKL_LIBRARIES} ${ZLIB_LIBRARIES} )
|
target_link_libraries( nglib ${LIBPTHREAD} ${OCC_LIBRARIES} ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} ${TK_LIBRARY} ${TCL_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${X11_Xmu_LIB} ${JPEG_LIBRARIES} ${MKL_LIBRARIES} ${ZLIB_LIBRARIES} )
|
||||||
|
|
||||||
if(USE_PYTHON)
|
if(USE_PYTHON)
|
||||||
target_link_libraries(nglib ${PYTHON_LIBS})
|
target_link_libraries(nglib ${PYTHON_LIBS})
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
from os import environ
|
from os import environ
|
||||||
from sys import path
|
from sys import path
|
||||||
from sys import platform as __platform
|
from sys import platform as __platform
|
||||||
if __platform.startswith('linux') or __platform.startswith('darwin'):
|
if __platform.startswith('linux'):
|
||||||
path.append(environ['NETGENDIR']+'/../lib')
|
path.append(environ['NETGENDIR']+'/../lib')
|
||||||
if __platform.startswith('win'):
|
if __platform.startswith('win'):
|
||||||
path.append(environ['NETGENDIR'])
|
path.append(environ['NETGENDIR'])
|
||||||
|
if __platform.startswith('darwin'):
|
||||||
|
path.append(environ['NETGENDIR'])
|
||||||
|
|
||||||
|
|
||||||
# from libngpy import *
|
# from libngpy import *
|
||||||
import libngpy
|
import libngpy
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user