mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 21:40:33 +05:00
including togl
This commit is contained in:
parent
cd1b288c43
commit
eeac7442f3
@ -8,3 +8,4 @@ SUBDIRS = libsrc ng tutorials doc windows nglib
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -239,14 +239,15 @@ AM_CONDITIONAL([NGPYTHON], [test x$pythonon = xtrue])
|
||||
# echo "libs = $LIBS"
|
||||
# echo "TOGL_LIB = $MYTOGL_LIB"
|
||||
|
||||
AC_CONFIG_SUBDIRS([ng/Togl-1.7])
|
||||
|
||||
AC_CONFIG_FILES(Makefile libsrc/Makefile libsrc/csg/Makefile
|
||||
libsrc/general/Makefile libsrc/geom2d/Makefile libsrc/gprim/Makefile
|
||||
libsrc/include/Makefile libsrc/interface/Makefile
|
||||
libsrc/linalg/Makefile libsrc/meshing/Makefile libsrc/occ/Makefile
|
||||
libsrc/stlgeom/Makefile
|
||||
libsrc/visualization/Makefile ng/Makefile nglib/Makefile
|
||||
tutorials/Makefile doc/Makefile windows/Makefile )
|
||||
libsrc/stlgeom/Makefile
|
||||
libsrc/visualization/Makefile ng/Makefile nglib/Makefile
|
||||
tutorials/Makefile doc/Makefile windows/Makefile )
|
||||
|
||||
AC_OUTPUT
|
||||
|
||||
|
@ -2,6 +2,7 @@ include_HEADERS =
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include -I$(top_srcdir)/libsrc/interface -DOPENGL -D$(TOGL_WINDOWINGSYSTEM) $(TCL_INCLUDES) $(MPI_INCLUDES) $(FFMPEG_INCLUDES) $(JPEGLIB_INCLUDES)
|
||||
|
||||
SUBDIRS = Togl-1.7
|
||||
|
||||
if NGGUI
|
||||
bin_PROGRAMS = netgen
|
||||
|
72
ng/Togl-1.7/.indent.pro
vendored
Normal file
72
ng/Togl-1.7/.indent.pro
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
--blank-before-sizeof
|
||||
--blank-lines-after-declarations
|
||||
--blank-lines-after-procedures
|
||||
--blank-lines-before-block-comments
|
||||
--braces-after-struct-decl-line
|
||||
--braces-on-if-line
|
||||
--break-before-boolean-operator
|
||||
--case-brace-indentation0
|
||||
--case-indentation2
|
||||
--comment-line-length80
|
||||
--continuation-indentation8
|
||||
--cuddle-do-while
|
||||
--cuddle-else
|
||||
--declaration-indentation8
|
||||
--dont-line-up-parentheses
|
||||
--format-all-comments
|
||||
--format-first-column-comments
|
||||
--indent-level4
|
||||
--leave-optional-blank-lines
|
||||
--line-length80
|
||||
--no-space-after-function-call-names
|
||||
--no-space-after-parentheses
|
||||
--no-tabs
|
||||
--parameter-indentation8
|
||||
--preprocessor-indentation2
|
||||
--procnames-start-lines
|
||||
--space-after-cast
|
||||
--space-after-for
|
||||
--space-after-if
|
||||
--space-after-while
|
||||
--space-special-semicolon
|
||||
--start-left-side-of-comments
|
||||
--struct-brace-indentation0
|
||||
--tab-size8
|
||||
-T AGLContext
|
||||
-T CALLBACK
|
||||
-T ClientData
|
||||
-T Colormap
|
||||
-T Display
|
||||
-T GLXContext
|
||||
-T GLbitfield
|
||||
-T GLboolean
|
||||
-T GLenum
|
||||
-T GLfloat
|
||||
-T GLint
|
||||
-T GLuint
|
||||
-T HDC
|
||||
-T HGLRC
|
||||
-T HWND
|
||||
-T LPARAM
|
||||
-T PIXELFORMATDESCRIPTOR
|
||||
-T Tcl_Command
|
||||
-T Tcl_Interp
|
||||
-T TkClassCreateProc
|
||||
-T TkClassGeometryProc
|
||||
-T TkClassModalProc
|
||||
-T TkClassProcs
|
||||
-T TkWinColormap
|
||||
-T Tk_ConfigSpec
|
||||
-T Tk_Cursor
|
||||
-T Tk_Window
|
||||
-T Togl_Callback
|
||||
-T Togl_CmdProc
|
||||
-T UINT
|
||||
-T WPARAM
|
||||
-T WinFont
|
||||
-T Window
|
||||
-T XColor
|
||||
-T XEvent
|
||||
-T XVisualInfo
|
||||
-T TOGL_EXTERN
|
||||
-T Togl
|
27
ng/Togl-1.7/LICENSE
Normal file
27
ng/Togl-1.7/LICENSE
Normal file
@ -0,0 +1,27 @@
|
||||
This software is copyrighted by Brian Paul (brian@mesa3d.org)
|
||||
and Benjamin Bederson (bederson@cs.umd.edu). 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.
|
471
ng/Togl-1.7/Makefile.in
Normal file
471
ng/Togl-1.7/Makefile.in
Normal file
@ -0,0 +1,471 @@
|
||||
# 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.7 2006/01/06 00:09:00 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@
|
||||
|
||||
DEMO_SRCS = double.c gears.c index.c overlay.c stereo.c texture.c
|
||||
DEMO_OBJS = $(DEMO_SRCS:.c=.$(OBJEXT))
|
||||
DEMO_SHLIBS = $(DEMO_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@
|
||||
|
||||
lib_BINARIES = $(PKG_LIB_FILE)
|
||||
BINARIES = $(lib_BINARIES)
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
libdir = @libdir@
|
||||
datadir = @datadir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
|
||||
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@
|
||||
CLEANFILES = @CLEANFILES@ $(DEMO_OBJS) $(DEMO_SHLIBS)
|
||||
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 = @PKG_INCLUDES@ @TCL_INCLUDES@
|
||||
INCLUDES = @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@ $(PKG_CFLAGS)
|
||||
|
||||
CONFIG_CLEAN_FILES = Makefile
|
||||
|
||||
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 inclues 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:
|
||||
|
||||
|
||||
#========================================================================
|
||||
# Demo section. These are binaries 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.
|
||||
#========================================================================
|
||||
|
||||
demos: $(DEMO_SHLIBS)
|
||||
|
||||
double$(SHLIB_SUFFIX): double.$(OBJEXT) togl.$(OBJEXT)
|
||||
$(SHLIB_LD) -o $@ double.$(OBJEXT) togl.$(OBJEXT) $(SHLIB_LD_LIBS)
|
||||
|
||||
gears$(SHLIB_SUFFIX): gears.$(OBJEXT) togl.$(OBJEXT)
|
||||
$(SHLIB_LD) -o $@ gears.$(OBJEXT) togl.$(OBJEXT) $(SHLIB_LD_LIBS) $(MATH_LIBS)
|
||||
|
||||
index$(SHLIB_SUFFIX): index.$(OBJEXT) togl.$(OBJEXT)
|
||||
$(SHLIB_LD) -o $@ index.$(OBJEXT) togl.$(OBJEXT) $(SHLIB_LD_LIBS)
|
||||
|
||||
overlay$(SHLIB_SUFFIX): overlay.$(OBJEXT) togl.$(OBJEXT)
|
||||
$(SHLIB_LD) -o $@ overlay.$(OBJEXT) togl.$(OBJEXT) $(SHLIB_LD_LIBS)
|
||||
|
||||
stereo$(SHLIB_SUFFIX): stereo.$(OBJEXT) togl.$(OBJEXT)
|
||||
$(SHLIB_LD) -o $@ stereo.$(OBJEXT) togl.$(OBJEXT) $(SHLIB_LD_LIBS)
|
||||
|
||||
texture$(SHLIB_SUFFIX): texture.$(OBJEXT) image.$(OBJEXT) togl.$(OBJEXT)
|
||||
$(SHLIB_LD) -o $@ texture.$(OBJEXT) image.$(OBJEXT) \
|
||||
togl.$(OBJEXT) $(LIBGLU) $(SHLIB_LD_LIBS)
|
||||
|
||||
#========================================================================
|
||||
# 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):$(srcdir)/generic:$(srcdir)/unix:$(srcdir)/win
|
||||
|
||||
.c.@OBJEXT@:
|
||||
$(COMPILE) -c `@CYGPATH@ $<` -o $@
|
||||
|
||||
#========================================================================
|
||||
# Distribution creation
|
||||
# You may need to tweak this target to make it work correctly.
|
||||
#========================================================================
|
||||
|
||||
#COMPRESS = tar cvf $(PKG_DIR).tar $(PKG_DIR); compress $(PKG_DIR).tar
|
||||
COMPRESS = gtar zcvf $(PKG_DIR).tar.gz $(PKG_DIR)
|
||||
DIST_ROOT = /tmp/dist
|
||||
DIST_DIR = $(DIST_ROOT)/$(PKG_DIR)
|
||||
|
||||
dist-clean:
|
||||
rm -rf $(DIST_DIR) $(DIST_ROOT)/$(PKG_DIR).tar.*
|
||||
|
||||
dist: dist-clean
|
||||
mkdir -p $(DIST_DIR)
|
||||
cp -p $(srcdir)/ChangeLog $(srcdir)/README* $(srcdir)/license* \
|
||||
$(srcdir)/aclocal.m4 $(srcdir)/configure $(srcdir)/*.in \
|
||||
$(DIST_DIR)/
|
||||
chmod 664 $(DIST_DIR)/Makefile.in $(DIST_DIR)/aclocal.m4
|
||||
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;
|
||||
|
||||
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='demos doc generic library mac tests unix win'; \
|
||||
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);)
|
||||
|
||||
#========================================================================
|
||||
# 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)$(pkglibdir)
|
||||
@list='$(lib_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); \
|
||||
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='$(lib_BINARIES)'; for p in $$list; do \
|
||||
rm -f $(DESTDIR)$(pkglibdir)/$$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:
|
21
ng/Togl-1.7/README.stubs
Normal file
21
ng/Togl-1.7/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
|
20
ng/Togl-1.7/TODO
Normal file
20
ng/Togl-1.7/TODO
Normal file
@ -0,0 +1,20 @@
|
||||
In no particular order:
|
||||
-----------------------
|
||||
|
||||
stubify C API.
|
||||
|
||||
replace EPS support with TK photo image support
|
||||
|
||||
Add command arguments for create, destroy, etc. so there would be a
|
||||
-createcommand option to the togl command (etc.) (and phase out
|
||||
Togl_*Func from the C API)
|
||||
|
||||
multisampling support (can be worked-around by passing in a pixelformat)
|
||||
|
||||
add vertical sync control
|
||||
|
||||
update documention
|
||||
- update build instructions
|
||||
- update stereo documentation
|
||||
- separate Tcl API from C API
|
||||
- say togl hides window system dependent (glX/wgl/agl) calls
|
1081
ng/Togl-1.7/Togl.html
Normal file
1081
ng/Togl-1.7/Togl.html
Normal file
File diff suppressed because it is too large
Load Diff
9
ng/Togl-1.7/aclocal.m4
vendored
Normal file
9
ng/Togl-1.7/aclocal.m4
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
#
|
||||
# Include the TEA standard macro set
|
||||
#
|
||||
|
||||
builtin(include,tclconfig/tcl.m4)
|
||||
|
||||
#
|
||||
# Add here whatever m4 macros you want to define for your package
|
||||
#
|
BIN
ng/Togl-1.7/ben.rgb
Normal file
BIN
ng/Togl-1.7/ben.rgb
Normal file
Binary file not shown.
9300
ng/Togl-1.7/configure
vendored
Executable file
9300
ng/Togl-1.7/configure
vendored
Executable file
File diff suppressed because it is too large
Load Diff
222
ng/Togl-1.7/configure.in
Normal file
222
ng/Togl-1.7/configure.in
Normal file
@ -0,0 +1,222 @@
|
||||
#!/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.6 2006/01/06 00:09:00 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], [1.7])
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# 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.4])
|
||||
|
||||
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.
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
TEA_ADD_SOURCES([togl.c])
|
||||
# togl_ws.h is added in Makefile.in because it is generated
|
||||
TEA_ADD_HEADERS([togl.h])
|
||||
TEA_ADD_INCLUDES([])
|
||||
TEA_ADD_LIBS([])
|
||||
TEA_ADD_CFLAGS([])
|
||||
TEA_ADD_STUB_SOURCES([])
|
||||
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.
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
if test "${TEA_PLATFORM}" = "windows" ; then
|
||||
AC_DEFINE(BUILD_togl, 1, [Build windows export dll])
|
||||
CLEANFILES="pkgIndex.tcl togl_ws.h *.lib *.dll *.exp *.ilk *.pdb vc*.pch"
|
||||
#TEA_ADD_SOURCES([win/winFile.c])
|
||||
#TEA_ADD_INCLUDES([-I\"$(${CYGPATH} ${srcdir}/win)\"])
|
||||
else
|
||||
CLEANFILES="pkgIndex.tcl togl_ws.h 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
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
TEA_PUBLIC_TCL_HEADERS
|
||||
#TEA_PRIVATE_TCL_HEADERS
|
||||
|
||||
#TEA_PUBLIC_TK_HEADERS
|
||||
TEA_PRIVATE_TK_HEADERS
|
||||
TEA_PATH_X
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# __CHANGE__
|
||||
# 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)
|
||||
TEA_ADD_LIBS([-lGL -lXmu])
|
||||
LIBGLU=-lGLU
|
||||
;;
|
||||
win32)
|
||||
AC_SUBST(TOGL_WINDOWINGSYSTEM,TOGL_WGL)
|
||||
TEA_ADD_LIBS([opengl32.lib user32.lib gdi32.lib])
|
||||
if test "$GCC" = "yes" ; then
|
||||
LIBGLU=-lglu32
|
||||
else
|
||||
LIBGLU=glu32.lib
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR([Unsupported windowing system: ${TEA_WINDOWINGSYSTEM}])
|
||||
;;
|
||||
esac
|
||||
AC_SUBST(LIBGLU)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# 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.
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
AC_DEFINE(USE_TCL_STUBS, 1, [Use Tcl stubs])
|
||||
AC_DEFINE(USE_TK_STUBS, 1, [Use Tk stubs])
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# 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
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# 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])
|
280
ng/Togl-1.7/double.c
Normal file
280
ng/Togl-1.7/double.c
Normal file
@ -0,0 +1,280 @@
|
||||
/* $Id: double.c,v 1.14 2005/04/23 07:49:13 gregcouch Exp $ */
|
||||
|
||||
/*
|
||||
* Togl - a Tk OpenGL widget
|
||||
* Copyright (C) 1996-1997 Brian Paul and Ben Bederson
|
||||
* See the LICENSE file for copyright details.
|
||||
*/
|
||||
|
||||
#include "togl.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* The following variable is a special hack that is needed in order for
|
||||
* Sun shared libraries to be used for Tcl.
|
||||
*/
|
||||
#ifdef SUN
|
||||
extern int matherr();
|
||||
int *tclDummyMathPtr = (int *) matherr;
|
||||
#endif
|
||||
|
||||
static GLuint FontBase;
|
||||
static float xAngle = 0.0, yAngle = 0.0, zAngle = 0.0;
|
||||
static GLfloat 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.
|
||||
*/
|
||||
void
|
||||
create_cb(Togl *togl)
|
||||
{
|
||||
|
||||
FontBase = Togl_LoadBitmapFont(togl, TOGL_BITMAP_8_BY_13);
|
||||
if (!FontBase) {
|
||||
printf("Couldn't load font!\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
void
|
||||
reshape_cb(Togl *togl)
|
||||
{
|
||||
int width = Togl_Width(togl);
|
||||
int height = Togl_Height(togl);
|
||||
float aspect = (float) width / (float) height;
|
||||
|
||||
glViewport(0, 0, width, height);
|
||||
|
||||
/* Set up projection transform */
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-aspect, aspect, -1.0, 1.0, 1.0, 10.0);
|
||||
|
||||
CornerX = -aspect;
|
||||
CornerY = -1.0;
|
||||
CornerZ = -1.1;
|
||||
|
||||
/* Change back to model view transform for rendering */
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
print_string(const char *s)
|
||||
{
|
||||
glCallLists(strlen(s), GL_UNSIGNED_BYTE, s);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
void
|
||||
display_cb(Togl *togl)
|
||||
{
|
||||
static GLuint cubeList = 0;
|
||||
const char *ident;
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glLoadIdentity(); /* Reset modelview matrix to the identity
|
||||
* matrix */
|
||||
glTranslatef(0.0, 0.0, -3.0); /* Move the camera back three units */
|
||||
glRotatef(xAngle, 1.0, 0.0, 0.0); /* Rotate by X, Y, and Z angles */
|
||||
glRotatef(yAngle, 0.0, 1.0, 0.0);
|
||||
glRotatef(zAngle, 0.0, 0.0, 1.0);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
if (!cubeList) {
|
||||
cubeList = glGenLists(1);
|
||||
glNewList(cubeList, GL_COMPILE);
|
||||
|
||||
/* Front face */
|
||||
glBegin(GL_QUADS);
|
||||
glColor3f(0.0, 0.7, 0.1); /* Green */
|
||||
glVertex3f(-1.0, 1.0, 1.0);
|
||||
glVertex3f(1.0, 1.0, 1.0);
|
||||
glVertex3f(1.0, -1.0, 1.0);
|
||||
glVertex3f(-1.0, -1.0, 1.0);
|
||||
/* Back face */
|
||||
glColor3f(0.9, 1.0, 0.0); /* Yellow */
|
||||
glVertex3f(-1.0, 1.0, -1.0);
|
||||
glVertex3f(1.0, 1.0, -1.0);
|
||||
glVertex3f(1.0, -1.0, -1.0);
|
||||
glVertex3f(-1.0, -1.0, -1.0);
|
||||
/* Top side face */
|
||||
glColor3f(0.2, 0.2, 1.0); /* Blue */
|
||||
glVertex3f(-1.0, 1.0, 1.0);
|
||||
glVertex3f(1.0, 1.0, 1.0);
|
||||
glVertex3f(1.0, 1.0, -1.0);
|
||||
glVertex3f(-1.0, 1.0, -1.0);
|
||||
/* Bottom side face */
|
||||
glColor3f(0.7, 0.0, 0.1); /* Red */
|
||||
glVertex3f(-1.0, -1.0, 1.0);
|
||||
glVertex3f(1.0, -1.0, 1.0);
|
||||
glVertex3f(1.0, -1.0, -1.0);
|
||||
glVertex3f(-1.0, -1.0, -1.0);
|
||||
glEnd();
|
||||
|
||||
glEndList();
|
||||
|
||||
}
|
||||
glCallList(cubeList);
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glLoadIdentity();
|
||||
glColor3f(1.0, 1.0, 1.0);
|
||||
glRasterPos3f(CornerX, CornerY, CornerZ);
|
||||
glListBase(FontBase);
|
||||
ident = Togl_Ident(togl);
|
||||
if (strcmp(ident, "Single") == 0) {
|
||||
print_string("Single buffered");
|
||||
} else {
|
||||
print_string("Double buffered");
|
||||
}
|
||||
Togl_SwapBuffers(togl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int
|
||||
setXrot_cb(Togl *togl, int argc, CONST84 char *argv[])
|
||||
{
|
||||
Tcl_Interp *interp = Togl_Interp(togl);
|
||||
|
||||
/* error checking */
|
||||
if (argc != 3) {
|
||||
Tcl_SetResult(interp,
|
||||
"wrong # args: should be \"pathName setXrot ?angle?\"",
|
||||
TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
xAngle = atof(argv[2]);
|
||||
|
||||
/* printf( "before %f ", xAngle ); */
|
||||
|
||||
if (xAngle < 0.0) {
|
||||
xAngle += 360.0;
|
||||
} else if (xAngle > 360.0) {
|
||||
xAngle -= 360.0;
|
||||
}
|
||||
|
||||
/* printf( "after %f \n", xAngle ); */
|
||||
|
||||
Togl_PostRedisplay(togl);
|
||||
|
||||
/* Let result string equal value */
|
||||
strcpy(interp->result, argv[2]);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
setYrot_cb(Togl *togl, int argc, CONST84 char *argv[])
|
||||
{
|
||||
Tcl_Interp *interp = Togl_Interp(togl);
|
||||
|
||||
/* error checking */
|
||||
if (argc != 3) {
|
||||
Tcl_SetResult(interp,
|
||||
"wrong # args: should be \"pathName setYrot ?angle?\"",
|
||||
TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
yAngle = atof(argv[2]);
|
||||
|
||||
if (yAngle < 0.0) {
|
||||
yAngle += 360.0;
|
||||
} else if (yAngle > 360.0) {
|
||||
yAngle -= 360.0;
|
||||
}
|
||||
|
||||
Togl_PostRedisplay(togl);
|
||||
|
||||
/* Let result string equal value */
|
||||
strcpy(interp->result, argv[2]);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
int
|
||||
getXrot_cb(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
|
||||
{
|
||||
sprintf(interp->result, "%d", (int) xAngle);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
int
|
||||
getYrot_cb(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
|
||||
{
|
||||
sprintf(interp->result, "%d", (int) yAngle);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Called by Tk_Main() to let me initialize the modules (Togl) I will need.
|
||||
*/
|
||||
TOGL_EXTERN int
|
||||
Double_Init(Tcl_Interp *interp)
|
||||
{
|
||||
#ifdef USE_TCL_STUBS
|
||||
if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_TK_STUBS
|
||||
if (Tk_InitStubs(interp, "8.1", 0) == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Togl_Init(interp) == TCL_ERROR) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
#ifdef macintosh
|
||||
Togl_MacSetupMainInterp(interp);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Specify the C callback functions for widget creation, display,
|
||||
* and reshape.
|
||||
*/
|
||||
Togl_CreateFunc(create_cb);
|
||||
Togl_DisplayFunc(display_cb);
|
||||
Togl_ReshapeFunc(reshape_cb);
|
||||
|
||||
/*
|
||||
* Make a new Togl widget command so the Tcl code can set a C variable.
|
||||
*/
|
||||
|
||||
Togl_CreateCommand("setXrot", setXrot_cb);
|
||||
Togl_CreateCommand("setYrot", setYrot_cb);
|
||||
|
||||
/*
|
||||
* Call Tcl_CreateCommand for application-specific commands, if
|
||||
* they weren't already created by the init procedures called above.
|
||||
*/
|
||||
|
||||
Tcl_CreateCommand(interp, "getXrot", (Tcl_CmdProc *) getXrot_cb,
|
||||
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
|
||||
Tcl_CreateCommand(interp, "getYrot", (Tcl_CmdProc *) getYrot_cb,
|
||||
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
|
||||
return TCL_OK;
|
||||
}
|
103
ng/Togl-1.7/double.tcl
Normal file
103
ng/Togl-1.7/double.tcl
Normal file
@ -0,0 +1,103 @@
|
||||
#!/bin/sh
|
||||
# the next line restarts using wish \
|
||||
exec wish "$0" "$@"
|
||||
|
||||
# $Id: double.tcl,v 1.5 2001/12/20 13:59:31 beskow Exp $
|
||||
|
||||
# Togl - a Tk OpenGL widget
|
||||
# Copyright (C) 1996 Brian Paul and Ben Bederson
|
||||
# See the LICENSE file for copyright details.
|
||||
|
||||
|
||||
# $Log: double.tcl,v $
|
||||
# Revision 1.5 2001/12/20 13:59:31 beskow
|
||||
# Improved error-handling in togl.c in case of window creation failure
|
||||
# Added pkgIndex target to makefile
|
||||
# Updated documentation to reflect stubs-interface (Togl.html + new README.stubs)
|
||||
# Added tk8.4a3 headers
|
||||
# Removed obsolete Tk internal headers
|
||||
#
|
||||
# Revision 1.4 2001/01/29 18:11:53 brianp
|
||||
# Jonas Beskow's changes to use Tcl/Tk stub interface
|
||||
#
|
||||
# Revision 1.3 1998/03/12 03:52:31 brianp
|
||||
# now sharing display lists between the widgets
|
||||
#
|
||||
# Revision 1.2 1996/10/23 23:31:56 brianp
|
||||
# added -ident options to togl calls
|
||||
#
|
||||
# Revision 1.1 1996/10/23 23:17:22 brianp
|
||||
# Initial revision
|
||||
#
|
||||
|
||||
|
||||
# An Tk/OpenGL widget demo with two windows, one single buffered and the
|
||||
# other double buffered.
|
||||
|
||||
load [file dirname [info script]]/double[info sharedlibextension]
|
||||
|
||||
proc setup {} {
|
||||
wm title . "Single vs Double Buffering"
|
||||
|
||||
frame .f1
|
||||
|
||||
# create first Togl widget
|
||||
togl .f1.o1 -width 200 -height 200 -rgba true -double false -depth true -ident Single
|
||||
|
||||
# create second Togl widget, share display lists with first widget
|
||||
togl .f1.o2 -width 200 -height 200 -rgba true -double true -depth true -ident Double -sharelist Single
|
||||
|
||||
scale .sx -label {X Axis} -from 0 -to 360 -command {setAngle x} -orient horizontal
|
||||
scale .sy -label {Y Axis} -from 0 -to 360 -command {setAngle y} -orient horizontal
|
||||
button .btn -text Quit -command exit
|
||||
|
||||
bind .f1.o1 <B1-Motion> {
|
||||
motion_event [lindex [%W config -width] 4] \
|
||||
[lindex [%W config -height] 4] \
|
||||
%x %y
|
||||
}
|
||||
|
||||
bind .f1.o2 <B1-Motion> {
|
||||
motion_event [lindex [%W config -width] 4] \
|
||||
[lindex [%W config -height] 4] \
|
||||
%x %y
|
||||
}
|
||||
|
||||
pack .f1.o1 .f1.o2 -side left -padx 3 -pady 3 -fill both -expand t
|
||||
pack .f1 -fill both -expand t
|
||||
pack .sx -fill x
|
||||
pack .sy -fill x
|
||||
pack .btn -fill x
|
||||
}
|
||||
|
||||
|
||||
|
||||
# This is called when mouse button 1 is pressed and moved in either of
|
||||
# the OpenGL windows.
|
||||
proc motion_event { width height x y } {
|
||||
.f1.o1 setXrot [expr 360.0 * $y / $height]
|
||||
.f1.o2 setXrot [expr 360.0 * $y / $height]
|
||||
.f1.o1 setYrot [expr 360.0 * ($width - $x) / $width]
|
||||
.f1.o2 setYrot [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 setAngle {axis value} {
|
||||
global xAngle yAngle zAngle
|
||||
|
||||
switch -exact $axis {
|
||||
x {.f1.o1 setXrot $value
|
||||
.f1.o2 setXrot $value}
|
||||
y {.f1.o1 setYrot $value
|
||||
.f1.o2 setYrot $value}
|
||||
}
|
||||
}
|
||||
|
||||
# Execution starts here!
|
||||
setup
|
402
ng/Togl-1.7/gears.c
Normal file
402
ng/Togl-1.7/gears.c
Normal file
@ -0,0 +1,402 @@
|
||||
/* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#include "togl.h"
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef M_PI
|
||||
# define M_PI 3.14159265
|
||||
#endif
|
||||
|
||||
struct WHIRLYGIZMO
|
||||
{
|
||||
GLint Gear1, Gear2, Gear3;
|
||||
GLfloat Rotx, Roty, Rotz;
|
||||
GLfloat Angle;
|
||||
int Height, Width;
|
||||
};
|
||||
|
||||
/*
|
||||
* 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.0;
|
||||
r2 = outer_radius + tooth_depth / 2.0;
|
||||
|
||||
da = 2.0 * M_PI / teeth / 4.0;
|
||||
|
||||
glShadeModel(GL_FLAT);
|
||||
|
||||
glNormal3f(0.0, 0.0, 1.0);
|
||||
|
||||
/* draw front face */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i <= teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
width * 0.5);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw front sides of teeth */
|
||||
glBegin(GL_QUADS);
|
||||
da = 2.0 * M_PI / teeth / 4.0;
|
||||
for (i = 0; i < teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||
width * 0.5);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
width * 0.5);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
|
||||
glNormal3f(0.0, 0.0, -1.0);
|
||||
|
||||
/* draw back face */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i <= teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
-width * 0.5);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw back sides of teeth */
|
||||
glBegin(GL_QUADS);
|
||||
da = 2.0 * M_PI / teeth / 4.0;
|
||||
for (i = 0; i < teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
-width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||
-width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
|
||||
/* draw outward faces of teeth */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i < teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
|
||||
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.0);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
|
||||
glNormal3f(cos(angle), sin(angle), 0.0);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||
width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||
-width * 0.5);
|
||||
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.0);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
width * 0.5);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
-width * 0.5);
|
||||
glNormal3f(cos(angle), sin(angle), 0.0);
|
||||
}
|
||||
|
||||
glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5);
|
||||
glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5);
|
||||
|
||||
glEnd();
|
||||
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
/* draw inside radius cylinder */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i <= teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
glNormal3f(-cos(angle), -sin(angle), 0.0);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* static GLfloat view_rotx=20.0, view_roty=30.0, view_rotz=0.0; static GLint
|
||||
* gear1, gear2, gear3; static GLfloat angle = 0.0; */
|
||||
static GLuint limit;
|
||||
static GLuint count = 1;
|
||||
|
||||
static GLubyte polycolor[4] = { 255, 255, 255, 255 };
|
||||
|
||||
static void
|
||||
draw(Togl *togl)
|
||||
{
|
||||
struct WHIRLYGIZMO *Wg;
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
Wg = Togl_GetClientData(togl);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glPushMatrix();
|
||||
glRotatef(Wg->Rotx, 1.0, 0.0, 0.0);
|
||||
glRotatef(Wg->Roty, 0.0, 1.0, 0.0);
|
||||
glRotatef(Wg->Rotz, 0.0, 0.0, 1.0);
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(-3.0, -2.0, 0.0);
|
||||
glRotatef(Wg->Angle, 0.0, 0.0, 1.0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glCallList(Wg->Gear1);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(3.1, -2.0, 0.0);
|
||||
glRotatef(-2.0 * Wg->Angle - 9.0, 0.0, 0.0, 1.0);
|
||||
glCallList(Wg->Gear2);
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(-3.1, 4.2, 0.0);
|
||||
glRotatef(-2.0 * Wg->Angle - 25.0, 0.0, 0.0, 1.0);
|
||||
glCallList(Wg->Gear3);
|
||||
glPopMatrix();
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
Togl_SwapBuffers(togl);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
zap(Togl *togl)
|
||||
{
|
||||
struct WHIRLYGIZMO *Wg;
|
||||
|
||||
Wg = Togl_GetClientData(togl);
|
||||
free(Wg);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
idle(Togl *togl)
|
||||
{
|
||||
struct WHIRLYGIZMO *Wg;
|
||||
|
||||
Wg = Togl_GetClientData(togl);
|
||||
Wg->Angle += 2.0;
|
||||
Togl_PostRedisplay(togl);
|
||||
}
|
||||
|
||||
|
||||
/* change view angle, exit upon ESC */
|
||||
/*
|
||||
* static GLenum key(int k, GLenum mask) { switch (k) { case TK_UP: view_rotx
|
||||
* += 5.0; return GL_TRUE; case TK_DOWN: view_rotx -= 5.0; return GL_TRUE; case
|
||||
* TK_LEFT: view_roty += 5.0; return GL_TRUE; case TK_RIGHT: view_roty -= 5.0;
|
||||
* return GL_TRUE; case TK_z: view_rotz += 5.0; return GL_TRUE; case TK_Z:
|
||||
* view_rotz -= 5.0; return GL_TRUE; } return GL_FALSE; } */
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(Togl *togl)
|
||||
{
|
||||
int width, height;
|
||||
|
||||
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.0, 1.0, 5.0, 60.0);
|
||||
} else {
|
||||
GLfloat h = (GLfloat) height / (GLfloat) width;
|
||||
|
||||
glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0);
|
||||
}
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -40.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
init(Togl *togl)
|
||||
{
|
||||
struct WHIRLYGIZMO *Wg;
|
||||
|
||||
static GLfloat red[4] = { 0.8, 0.1, 0.0, 1.0 };
|
||||
static GLfloat green[4] = { 0.0, 0.8, 0.2, 1.0 };
|
||||
static GLfloat blue[4] = { 0.2, 0.2, 1.0, 1.0 };
|
||||
static GLfloat pos[4] = { 5.0, 5.0, 10.0, 0.0 };
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, pos);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
/* make the gears */
|
||||
Wg = malloc(sizeof (*Wg));
|
||||
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.0, 4.0, 1.0, 20, 0.7);
|
||||
glEndList();
|
||||
|
||||
Wg->Gear2 = glGenLists(1);
|
||||
glNewList(Wg->Gear2, GL_COMPILE);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
|
||||
gear(0.5, 2.0, 2.0, 10, 0.7);
|
||||
glEndList();
|
||||
|
||||
Wg->Gear3 = glGenLists(1);
|
||||
glNewList(Wg->Gear3, GL_COMPILE);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
|
||||
gear(1.3, 2.0, 0.5, 10, 0.7);
|
||||
glEndList();
|
||||
|
||||
glEnable(GL_NORMALIZE);
|
||||
Wg->Height = Togl_Height(togl);
|
||||
Wg->Width = Togl_Width(togl);
|
||||
Wg->Angle = 0.0;
|
||||
Wg->Rotx = 0.0;
|
||||
Wg->Roty = 0.0;
|
||||
Wg->Rotz = 0.0;
|
||||
Togl_SetClientData(togl, (ClientData) Wg);
|
||||
}
|
||||
|
||||
int
|
||||
position(Togl *togl, int argc, CONST84 char *argv[])
|
||||
{
|
||||
struct WHIRLYGIZMO *Wg;
|
||||
Tcl_Interp *interp = Togl_Interp(togl);
|
||||
char Result[100];
|
||||
|
||||
Wg = Togl_GetClientData(togl);
|
||||
/* error checking */
|
||||
if (argc != 2) {
|
||||
Tcl_SetResult(interp,
|
||||
"wrong # args: should be \"pathName \"", TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/* Let result string equal value */
|
||||
sprintf(Result, "%g %g", Wg->Roty, Wg->Rotx);
|
||||
|
||||
Tcl_SetResult(interp, Result, TCL_VOLATILE);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
int
|
||||
rotate(Togl *togl, int argc, CONST84 char *argv[])
|
||||
{
|
||||
struct WHIRLYGIZMO *Wg;
|
||||
Tcl_Interp *interp = Togl_Interp(togl);
|
||||
|
||||
Wg = Togl_GetClientData(togl);
|
||||
/* error checking */
|
||||
if (argc != 4) {
|
||||
Tcl_SetResult(interp,
|
||||
"wrong # args: should be \"pathName xrot yrot\"", TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
Wg->Roty = atof(argv[2]);
|
||||
Wg->Rotx = atof(argv[3]);
|
||||
Togl_PostRedisplay(togl);
|
||||
|
||||
/* Let result string equal value */
|
||||
strcpy(interp->result, argv[2]);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
TOGL_EXTERN int
|
||||
Gears_Init(Tcl_Interp *interp)
|
||||
{
|
||||
/*
|
||||
* Initialize Tcl, Tk, and the Togl widget module.
|
||||
*/
|
||||
#ifdef USE_TCL_STUBS
|
||||
if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_TK_STUBS
|
||||
if (Tk_InitStubs(interp, "8.1", 0) == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Togl_Init(interp) == TCL_ERROR) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Specify the C callback functions for widget creation, display,
|
||||
* and reshape.
|
||||
*/
|
||||
Togl_CreateFunc(init);
|
||||
Togl_DestroyFunc(zap);
|
||||
Togl_DisplayFunc(draw);
|
||||
Togl_ReshapeFunc(reshape);
|
||||
Togl_TimerFunc(idle);
|
||||
Togl_CreateCommand("rotate", rotate);
|
||||
Togl_CreateCommand("position", position);
|
||||
return TCL_OK;
|
||||
}
|
76
ng/Togl-1.7/gears.tcl
Executable file
76
ng/Togl-1.7/gears.tcl
Executable file
@ -0,0 +1,76 @@
|
||||
#!/bin/sh
|
||||
# the next line restarts using wish \
|
||||
exec wish "$0" "$@"
|
||||
|
||||
# Togl - a Tk OpenGL widget
|
||||
# Copyright (C) 1996-1997 Brian Paul and Ben Bederson
|
||||
# See the LICENSE file for copyright details.
|
||||
|
||||
|
||||
#
|
||||
# Test Togl using GL Gears Demo
|
||||
#
|
||||
# Copyright (C) 1997 Philip Quaife
|
||||
#
|
||||
|
||||
load [file dirname [info script]]/gears[info sharedlibextension]
|
||||
|
||||
proc 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 AutoRot
|
||||
button .f.r1 -text "Remove" -command 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 AutoRot {} {
|
||||
global RotCnt vTime
|
||||
newRot .w$RotCnt $vTime
|
||||
set RotCnt [expr $RotCnt + 1]
|
||||
}
|
||||
|
||||
proc DelRot {} {
|
||||
global RotCnt vTime
|
||||
if { $RotCnt != 0 } {
|
||||
set RotCnt [expr $RotCnt - 1]
|
||||
destroy .w$RotCnt
|
||||
}
|
||||
}
|
||||
|
||||
proc newRot {win {tick 100} } {
|
||||
togl $win -width 200 -height 200 -rgba true -double true -depth true -privatecmap false -time $tick
|
||||
bind $win <ButtonPress-1> {RotStart %x %y %W}
|
||||
bind $win <B1-Motion> {RotMove %x %y %W}
|
||||
pack $win -expand true -fill both
|
||||
}
|
||||
|
||||
proc RotStart {x y W } {
|
||||
global startx starty xangle0 yangle0 xangle yangle
|
||||
set startx $x
|
||||
set starty $y
|
||||
set vPos [$W position]
|
||||
set xangle0 [lindex $vPos 0]
|
||||
set yangle0 [lindex $vPos 1]
|
||||
}
|
||||
|
||||
proc RotMove {x y W} {
|
||||
global startx starty xangle0 yangle0 xangle yangle
|
||||
set xangle [expr $xangle0 + ($x - $startx) ]
|
||||
set yangle [expr $yangle0 + ($y - $starty) ]
|
||||
$W rotate $xangle $yangle
|
||||
}
|
||||
|
||||
setup
|
249
ng/Togl-1.7/image.c
Normal file
249
ng/Togl-1.7/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++ = (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(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(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/Togl-1.7/image.h
Normal file
14
ng/Togl-1.7/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(char *fileName);
|
||||
|
||||
#endif
|
184
ng/Togl-1.7/index.c
Normal file
184
ng/Togl-1.7/index.c
Normal file
@ -0,0 +1,184 @@
|
||||
/* $Id: index.c,v 1.10 2005/04/23 07:49:13 gregcouch Exp $ */
|
||||
|
||||
/*
|
||||
* Togl - a Tk OpenGL widget
|
||||
* Copyright (C) 1996-1997 Brian Paul and Ben Bederson
|
||||
* See the LICENSE file for copyright details.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* An example Togl program using color-index mode.
|
||||
*/
|
||||
|
||||
|
||||
#include "togl.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/*
|
||||
* The following variable is a special hack that is needed in order for
|
||||
* Sun shared libraries to be used for Tcl.
|
||||
*/
|
||||
#ifdef SUN
|
||||
extern int matherr();
|
||||
int *tclDummyMathPtr = (int *) matherr;
|
||||
#endif
|
||||
|
||||
|
||||
/* Our color indexes: */
|
||||
static unsigned long black, red, green, blue;
|
||||
|
||||
/* Rotation angle */
|
||||
static float Angle = 0.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.
|
||||
*/
|
||||
void
|
||||
create_cb(Togl *togl)
|
||||
{
|
||||
/* allocate color indexes */
|
||||
black = Togl_AllocColor(togl, 0.0, 0.0, 0.0);
|
||||
red = Togl_AllocColor(togl, 1.0, 0.0, 0.0);
|
||||
green = Togl_AllocColor(togl, 0.0, 1.0, 0.0);
|
||||
blue = Togl_AllocColor(togl, 0.0, 0.0, 1.0);
|
||||
|
||||
/* 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.0, 0.0 ); red = 2;
|
||||
* Togl_SetColor( togl, red, 1.0, 0.0, 0.0 ); green = 3; Togl_SetColor(
|
||||
* togl, green, 0.0, 1.0, 0.0 ); blue = 4; Togl_SetColor( togl, blue, 0.0,
|
||||
* 0.0, 1.0 ); */
|
||||
|
||||
glShadeModel(GL_FLAT);
|
||||
glDisable(GL_DITHER);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
void
|
||||
reshape_cb(Togl *togl)
|
||||
{
|
||||
int width = Togl_Width(togl);
|
||||
int height = Togl_Height(togl);
|
||||
float aspect = (float) width / (float) height;
|
||||
|
||||
glViewport(0, 0, width, height);
|
||||
|
||||
/* Set up projection transform */
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-aspect, aspect, -1.0, 1.0, -1.0, 1.0);
|
||||
|
||||
/* Change back to model view transform for rendering */
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
void
|
||||
display_cb(Togl *togl)
|
||||
{
|
||||
glClearIndex(black);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(0.3, -0.3, 0.0);
|
||||
glRotatef(Angle, 0.0, 0.0, 1.0);
|
||||
glIndexi(red);
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex2f(-0.5, -0.3);
|
||||
glVertex2f(0.5, -0.3);
|
||||
glVertex2f(0.0, 0.6);
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(Angle, 0.0, 0.0, 1.0);
|
||||
glIndexi(green);
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex2f(-0.5, -0.3);
|
||||
glVertex2f(0.5, -0.3);
|
||||
glVertex2f(0.0, 0.6);
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(-0.3, 0.3, 0.0);
|
||||
glRotatef(Angle, 0.0, 0.0, 1.0);
|
||||
glIndexi(blue);
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex2f(-0.5, -0.3);
|
||||
glVertex2f(0.5, -0.3);
|
||||
glVertex2f(0.0, 0.6);
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
|
||||
glFlush();
|
||||
Togl_SwapBuffers(togl);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
timer_cb(Togl *togl)
|
||||
{
|
||||
Angle += 5.0;
|
||||
Togl_PostRedisplay(togl);
|
||||
}
|
||||
|
||||
|
||||
TOGL_EXTERN int
|
||||
Index_Init(Tcl_Interp *interp)
|
||||
{
|
||||
/*
|
||||
* Initialize Tcl, Tk, and the Togl widget module.
|
||||
*/
|
||||
#ifdef USE_TCL_STUBS
|
||||
if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_TK_STUBS
|
||||
if (Tk_InitStubs(interp, "8.1", 0) == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Togl_Init(interp) == TCL_ERROR) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Specify the C callback functions for widget creation, display,
|
||||
* and reshape.
|
||||
*/
|
||||
Togl_CreateFunc(create_cb);
|
||||
Togl_DisplayFunc(display_cb);
|
||||
Togl_ReshapeFunc(reshape_cb);
|
||||
Togl_TimerFunc(timer_cb);
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
51
ng/Togl-1.7/index.tcl
Normal file
51
ng/Togl-1.7/index.tcl
Normal file
@ -0,0 +1,51 @@
|
||||
#!/bin/sh
|
||||
# the next line restarts using wish \
|
||||
exec wish "$0" "$@"
|
||||
|
||||
# $Id: index.tcl,v 1.5 2001/12/20 13:59:31 beskow Exp $
|
||||
|
||||
# Togl - a Tk OpenGL widget
|
||||
# Copyright (C) 1996 Brian Paul and Ben Bederson
|
||||
# See the LICENSE file for copyright details.
|
||||
|
||||
|
||||
# $Log: index.tcl,v $
|
||||
# Revision 1.5 2001/12/20 13:59:31 beskow
|
||||
# Improved error-handling in togl.c in case of window creation failure
|
||||
# Added pkgIndex target to makefile
|
||||
# Updated documentation to reflect stubs-interface (Togl.html + new README.stubs)
|
||||
# Added tk8.4a3 headers
|
||||
# Removed obsolete Tk internal headers
|
||||
#
|
||||
# Revision 1.4 2001/01/29 18:11:53 brianp
|
||||
# Jonas Beskow's changes to use Tcl/Tk stub interface
|
||||
#
|
||||
# Revision 1.3 1998/01/24 14:05:50 brianp
|
||||
# added quit button (Ben Bederson)
|
||||
#
|
||||
# Revision 1.2 1997/04/11 01:37:34 brianp
|
||||
# added a timer to rotate the triangles
|
||||
#
|
||||
# Revision 1.1 1996/10/23 23:18:11 brianp
|
||||
# Initial revision
|
||||
#
|
||||
|
||||
|
||||
# A Tk/OpenGL widget demo using color-index mode.
|
||||
|
||||
load [file dirname [info script]]/index[info sharedlibextension]
|
||||
|
||||
proc setup {} {
|
||||
wm title . "Color index demo"
|
||||
|
||||
togl .win -width 200 -height 200 -rgba false -double true -privatecmap false -time 10
|
||||
button .btn -text Quit -command exit
|
||||
|
||||
pack .win -expand true -fill both
|
||||
pack .btn -expand true -fill both
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Execution starts here!
|
||||
setup
|
194
ng/Togl-1.7/overlay.c
Normal file
194
ng/Togl-1.7/overlay.c
Normal file
@ -0,0 +1,194 @@
|
||||
/* $Id: overlay.c,v 1.7 2005/04/23 07:49:13 gregcouch Exp $ */
|
||||
|
||||
/*
|
||||
* Togl - a Tk OpenGL widget
|
||||
* Copyright (C) 1996-1997 Brian Paul and Ben Bederson
|
||||
* See the LICENSE file for copyright details.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* An example Togl program using an overlay.
|
||||
*/
|
||||
|
||||
|
||||
#include "togl.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/*
|
||||
* The following variable is a special hack that is needed in order for
|
||||
* Sun shared libraries to be used for Tcl.
|
||||
*/
|
||||
#ifdef SUN
|
||||
extern int matherr();
|
||||
int *tclDummyMathPtr = (int *) matherr;
|
||||
#endif
|
||||
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
void
|
||||
create_cb(Togl *togl)
|
||||
{
|
||||
/* allocate overlay color indexes */
|
||||
Red = Togl_AllocColorOverlay(togl, 1.0, 0.0, 0.0);
|
||||
Green = Togl_AllocColorOverlay(togl, 0.0, 1.0, 0.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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
void
|
||||
reshape_cb(Togl *togl)
|
||||
{
|
||||
int width = Togl_Width(togl);
|
||||
int height = Togl_Height(togl);
|
||||
float 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.0, 1.0, -1.0, 1.0);
|
||||
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.0, 1.0, -1.0, 1.0, -1.0, 1.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
Togl_UseLayer(togl, TOGL_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Togl widget overlay display callback. This is called by Tcl/Tk when the
|
||||
* overlay has to be redrawn.
|
||||
*/
|
||||
void
|
||||
overlay_display_cb(Togl *togl)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glIndexi(Red);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(-1.0, -1.0);
|
||||
glVertex2f(1.0, 1.0);
|
||||
glVertex2f(-1.0, 1.0);
|
||||
glVertex2f(1.0, -1.0);
|
||||
glEnd();
|
||||
|
||||
glIndexi(Green);
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex2f(-0.5, -0.5);
|
||||
glVertex2f(0.5, -0.5);
|
||||
glVertex2f(0.5, 0.5);
|
||||
glVertex2f(-0.5, 0.5);
|
||||
glEnd();
|
||||
glFlush();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
void
|
||||
display_cb(Togl *togl)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glLoadIdentity();
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
|
||||
glColor3f(1.0, 0.0, 1.0);
|
||||
glVertex2f(-0.5, -0.3);
|
||||
glVertex2f(0.5, -0.3);
|
||||
glVertex2f(0.0, 0.6);
|
||||
|
||||
glColor3f(1.0, 1.0, 0.0);
|
||||
glVertex2f(-0.5 + 0.2, -0.3 - 0.2);
|
||||
glVertex2f(0.5 + 0.2, -0.3 - 0.2);
|
||||
glVertex2f(0.0 + 0.2, 0.6 - 0.2);
|
||||
|
||||
glColor3f(0.0, 1.0, 1.0);
|
||||
glVertex2f(-0.5 + 0.4, -0.3 - 0.4);
|
||||
glVertex2f(0.5 + 0.4, -0.3 - 0.4);
|
||||
glVertex2f(0.0 + 0.4, 0.6 - 0.4);
|
||||
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called by Tk_Main() to let me initialize the modules (Togl) I will need.
|
||||
*/
|
||||
TOGL_EXTERN int
|
||||
Overlay_Init(Tcl_Interp *interp)
|
||||
{
|
||||
/*
|
||||
* Initialize Tcl, Tk, and the Togl widget module.
|
||||
*/
|
||||
#ifdef USE_TCL_STUBS
|
||||
if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_TK_STUBS
|
||||
if (Tk_InitStubs(interp, "8.1", 0) == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
#endif
|
||||
if (Togl_Init(interp) == TCL_ERROR) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Specify the C callback functions for widget creation, display,
|
||||
* and reshape.
|
||||
*/
|
||||
Togl_CreateFunc(create_cb);
|
||||
Togl_DisplayFunc(display_cb);
|
||||
Togl_ReshapeFunc(reshape_cb);
|
||||
|
||||
Togl_OverlayDisplayFunc(overlay_display_cb);
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
49
ng/Togl-1.7/overlay.tcl
Normal file
49
ng/Togl-1.7/overlay.tcl
Normal file
@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
# the next line restarts using wish \
|
||||
exec wish "$0" "$@"
|
||||
|
||||
# $Id: overlay.tcl,v 1.4 2001/12/20 13:59:31 beskow Exp $
|
||||
|
||||
# Togl - a Tk OpenGL widget
|
||||
# Copyright (C) 1996 Brian Paul and Ben Bederson
|
||||
# See the LICENSE file for copyright details.
|
||||
|
||||
|
||||
# $Log: overlay.tcl,v $
|
||||
# Revision 1.4 2001/12/20 13:59:31 beskow
|
||||
# Improved error-handling in togl.c in case of window creation failure
|
||||
# Added pkgIndex target to makefile
|
||||
# Updated documentation to reflect stubs-interface (Togl.html + new README.stubs)
|
||||
# Added tk8.4a3 headers
|
||||
# Removed obsolete Tk internal headers
|
||||
#
|
||||
# Revision 1.3 2001/01/29 18:11:53 brianp
|
||||
# Jonas Beskow's changes to use Tcl/Tk stub interface
|
||||
#
|
||||
# Revision 1.2 1998/01/24 14:05:50 brianp
|
||||
# added quit button (Ben Bederson)
|
||||
#
|
||||
# Revision 1.1 1997/03/07 01:26:38 brianp
|
||||
# Initial revision
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
# A Tk/OpenGL widget demo using an overlay.
|
||||
|
||||
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
|
||||
button .btn -text Quit -command exit
|
||||
|
||||
pack .win -expand true -fill both
|
||||
pack .btn -expand true -fill both
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Execution starts here!
|
||||
setup
|
5
ng/Togl-1.7/pkgIndex.tcl.in
Normal file
5
ng/Togl-1.7/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@]]
|
352
ng/Togl-1.7/stereo.c
Normal file
352
ng/Togl-1.7/stereo.c
Normal file
@ -0,0 +1,352 @@
|
||||
/* $Id: stereo.c,v 1.6 2005/04/23 07:49:13 gregcouch Exp $ */
|
||||
|
||||
/*
|
||||
* Togl - a Tk OpenGL widget
|
||||
* Copyright (C) 1996-1997 Brian Paul and Ben Bederson
|
||||
* See the LICENSE file for copyright details.
|
||||
*/
|
||||
|
||||
#include "togl.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* The following variable is a special hack that is needed in order for
|
||||
* Sun shared libraries to be used for Tcl.
|
||||
*/
|
||||
#ifdef SUN
|
||||
extern int matherr();
|
||||
int *tclDummyMathPtr = (int *) matherr;
|
||||
#endif
|
||||
|
||||
|
||||
static GLuint FontBase;
|
||||
static float xAngle = 0.0, yAngle = 0.0, zAngle = 0.0;
|
||||
static GLfloat CornerX, CornerY, CornerZ; /* where to print strings */
|
||||
static GLfloat scale = 1.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.
|
||||
*/
|
||||
void
|
||||
create_cb(Togl *togl)
|
||||
{
|
||||
FontBase = Togl_LoadBitmapFont(togl, TOGL_BITMAP_8_BY_13);
|
||||
if (!FontBase) {
|
||||
printf("Couldn't load font!\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
void
|
||||
reshape_cb(Togl *togl)
|
||||
{
|
||||
int width = Togl_Width(togl);
|
||||
int height = Togl_Height(togl);
|
||||
float aspect = (float) width / (float) height;
|
||||
|
||||
glViewport(0, 0, width, height);
|
||||
|
||||
/* Set up projection transform */
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-aspect, aspect, -1.0, 1.0, 1.0, 10.0);
|
||||
|
||||
CornerX = -aspect;
|
||||
CornerY = -1.0;
|
||||
CornerZ = -1.1;
|
||||
|
||||
/* Change back to model view transform for rendering */
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
print_string(const char *s)
|
||||
{
|
||||
glCallLists(strlen(s), GL_UNSIGNED_BYTE, s);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
void
|
||||
display_cb(Togl *togl)
|
||||
{
|
||||
const char *ident;
|
||||
GLfloat eyeDist = 2.0;
|
||||
GLfloat eyeOffset = 0.05;
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glLoadIdentity(); /* Reset modelview matrix to the identity
|
||||
* matrix */
|
||||
glTranslatef(0.0, 0.0, -3.0); /* Move the camera back three units */
|
||||
glScalef(scale, scale, scale); /* Zoom in and out */
|
||||
glRotatef(xAngle, 1.0, 0.0, 0.0); /* Rotate by X, Y, and Z angles */
|
||||
glRotatef(yAngle, 0.0, 1.0, 0.0);
|
||||
glRotatef(zAngle, 0.0, 0.0, 1.0);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
/* stereo right eye */
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
Togl_StereoFrustum(-1, 1, -1, 1, 1, 10, eyeDist, eyeOffset);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
#ifdef OLD_STEREO
|
||||
Togl_OldStereoDrawBuffer(GL_BACK_RIGHT);
|
||||
Togl_OldStereoClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
#else
|
||||
glDrawBuffer(GL_BACK_RIGHT);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
#endif
|
||||
|
||||
/* Front face */
|
||||
glBegin(GL_QUADS);
|
||||
glColor3f(0.0, 0.7, 0.1); /* Green */
|
||||
glVertex3f(-1.0, 1.0, 1.0);
|
||||
glVertex3f(1.0, 1.0, 1.0);
|
||||
glVertex3f(1.0, -1.0, 1.0);
|
||||
glVertex3f(-1.0, -1.0, 1.0);
|
||||
/* Back face */
|
||||
glColor3f(0.9, 1.0, 0.0); /* Yellow */
|
||||
glVertex3f(-1.0, 1.0, -1.0);
|
||||
glVertex3f(1.0, 1.0, -1.0);
|
||||
glVertex3f(1.0, -1.0, -1.0);
|
||||
glVertex3f(-1.0, -1.0, -1.0);
|
||||
/* Top side face */
|
||||
glColor3f(0.2, 0.2, 1.0); /* Blue */
|
||||
glVertex3f(-1.0, 1.0, 1.0);
|
||||
glVertex3f(1.0, 1.0, 1.0);
|
||||
glVertex3f(1.0, 1.0, -1.0);
|
||||
glVertex3f(-1.0, 1.0, -1.0);
|
||||
/* Bottom side face */
|
||||
glColor3f(0.7, 0.0, 0.1); /* Red */
|
||||
glVertex3f(-1.0, -1.0, 1.0);
|
||||
glVertex3f(1.0, -1.0, 1.0);
|
||||
glVertex3f(1.0, -1.0, -1.0);
|
||||
glVertex3f(-1.0, -1.0, -1.0);
|
||||
glEnd();
|
||||
|
||||
/* stereo left eye */
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
Togl_StereoFrustum(-1, 1, -1, 1, 1, 10, eyeDist, -eyeOffset);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
#ifdef OLD_STEREO
|
||||
Togl_OldStereoDrawBuffer(GL_BACK_LEFT);
|
||||
Togl_OldStereoClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
#else
|
||||
glDrawBuffer(GL_BACK_LEFT);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
#endif
|
||||
|
||||
/* Front face */
|
||||
glBegin(GL_QUADS);
|
||||
glColor3f(0.0, 0.7, 0.1); /* Green */
|
||||
glVertex3f(-1.0, 1.0, 1.0);
|
||||
glVertex3f(1.0, 1.0, 1.0);
|
||||
glVertex3f(1.0, -1.0, 1.0);
|
||||
glVertex3f(-1.0, -1.0, 1.0);
|
||||
/* Back face */
|
||||
glColor3f(0.9, 1.0, 0.0); /* Yellow */
|
||||
glVertex3f(-1.0, 1.0, -1.0);
|
||||
glVertex3f(1.0, 1.0, -1.0);
|
||||
glVertex3f(1.0, -1.0, -1.0);
|
||||
glVertex3f(-1.0, -1.0, -1.0);
|
||||
/* Top side face */
|
||||
glColor3f(0.2, 0.2, 1.0); /* Blue */
|
||||
glVertex3f(-1.0, 1.0, 1.0);
|
||||
glVertex3f(1.0, 1.0, 1.0);
|
||||
glVertex3f(1.0, 1.0, -1.0);
|
||||
glVertex3f(-1.0, 1.0, -1.0);
|
||||
/* Bottom side face */
|
||||
glColor3f(0.7, 0.0, 0.1); /* Red */
|
||||
glVertex3f(-1.0, -1.0, 1.0);
|
||||
glVertex3f(1.0, -1.0, 1.0);
|
||||
glVertex3f(1.0, -1.0, -1.0);
|
||||
glVertex3f(-1.0, -1.0, -1.0);
|
||||
glEnd();
|
||||
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glLoadIdentity();
|
||||
glColor3f(1.0, 1.0, 1.0);
|
||||
glRasterPos3f(CornerX, CornerY, CornerZ);
|
||||
glListBase(FontBase);
|
||||
/* ident = Togl_Ident( togl ); if (strcmp(ident,"Single")==0) {
|
||||
* print_string( "Single buffered" ); } else { print_string( "Double
|
||||
* buffered" ); } */
|
||||
print_string(Togl_Ident(togl));
|
||||
Togl_SwapBuffers(togl);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
setXrot_cb(Togl *togl, int argc, CONST84 char *argv[])
|
||||
{
|
||||
Tcl_Interp *interp = Togl_Interp(togl);
|
||||
|
||||
/* error checking */
|
||||
if (argc != 3) {
|
||||
Tcl_SetResult(interp,
|
||||
"wrong # args: should be \"pathName setXrot ?angle?\"",
|
||||
TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
xAngle = atof(argv[2]);
|
||||
|
||||
/* printf( "before %f ", xAngle ); */
|
||||
|
||||
if (xAngle < 0.0) {
|
||||
xAngle += 360.0;
|
||||
} else if (xAngle > 360.0) {
|
||||
xAngle -= 360.0;
|
||||
}
|
||||
|
||||
/* printf( "after %f \n", xAngle ); */
|
||||
|
||||
Togl_PostRedisplay(togl);
|
||||
|
||||
/* Let result string equal value */
|
||||
strcpy(interp->result, argv[2]);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
setYrot_cb(Togl *togl, int argc, CONST84 char *argv[])
|
||||
{
|
||||
Tcl_Interp *interp = Togl_Interp(togl);
|
||||
|
||||
/* error checking */
|
||||
if (argc != 3) {
|
||||
Tcl_SetResult(interp,
|
||||
"wrong # args: should be \"pathName setYrot ?angle?\"",
|
||||
TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
yAngle = atof(argv[2]);
|
||||
|
||||
if (yAngle < 0.0) {
|
||||
yAngle += 360.0;
|
||||
} else if (yAngle > 360.0) {
|
||||
yAngle -= 360.0;
|
||||
}
|
||||
|
||||
Togl_PostRedisplay(togl);
|
||||
|
||||
/* Let result string equal value */
|
||||
strcpy(interp->result, argv[2]);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
getXrot_cb(ClientData clientData, Tcl_Interp *interp,
|
||||
int argc, CONST84 char *argv[])
|
||||
{
|
||||
sprintf(interp->result, "%d", (int) xAngle);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
getYrot_cb(ClientData clientData, Tcl_Interp *interp,
|
||||
int argc, CONST84 char *argv[])
|
||||
{
|
||||
sprintf(interp->result, "%d", (int) yAngle);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
scale_cb(Togl *togl, int argc, CONST84 char *argv[])
|
||||
{
|
||||
Tcl_Interp *interp = Togl_Interp(togl);
|
||||
|
||||
/* error checking */
|
||||
if (argc != 3) {
|
||||
Tcl_SetResult(interp,
|
||||
"wrong # args: should be \"pathName scale ?value?\"",
|
||||
TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
scale = atof(argv[2]);
|
||||
|
||||
Togl_PostRedisplay(togl);
|
||||
|
||||
/* Let result string equal value */
|
||||
strcpy(interp->result, argv[2]);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
TOGL_EXTERN int
|
||||
Stereo_Init(Tcl_Interp *interp)
|
||||
{
|
||||
/*
|
||||
* Initialize Tcl, Tk, and the Togl widget module.
|
||||
*/
|
||||
#ifdef USE_TCL_STUBS
|
||||
if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_TK_STUBS
|
||||
if (Tk_InitStubs(interp, "8.1", 0) == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Togl_Init(interp) == TCL_ERROR) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Specify the C callback functions for widget creation, display,
|
||||
* and reshape.
|
||||
*/
|
||||
Togl_CreateFunc(create_cb);
|
||||
Togl_DisplayFunc(display_cb);
|
||||
Togl_ReshapeFunc(reshape_cb);
|
||||
|
||||
/*
|
||||
* Make a new Togl widget command so the Tcl code can set a C variable.
|
||||
*/
|
||||
|
||||
Togl_CreateCommand("setXrot", setXrot_cb);
|
||||
Togl_CreateCommand("setYrot", setYrot_cb);
|
||||
Togl_CreateCommand("scale", scale_cb);
|
||||
|
||||
/*
|
||||
* 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, (ClientData) NULL,
|
||||
(Tcl_CmdDeleteProc *) NULL);
|
||||
Tcl_CreateCommand(interp, "getYrot", getYrot_cb, (ClientData) NULL,
|
||||
(Tcl_CmdDeleteProc *) NULL);
|
||||
|
||||
return TCL_OK;
|
||||
}
|
108
ng/Togl-1.7/stereo.tcl
Normal file
108
ng/Togl-1.7/stereo.tcl
Normal file
@ -0,0 +1,108 @@
|
||||
#!/bin/sh
|
||||
# the next line restarts using wish \
|
||||
exec wish "$0" "$@"
|
||||
|
||||
# $Id: stereo.tcl,v 1.4 2004/12/21 05:28:39 gregcouch Exp $
|
||||
|
||||
# Togl - a Tk OpenGL widget
|
||||
# Copyright (C) 1996 Brian Paul and Ben Bederson
|
||||
# See the LICENSE file for copyright details.
|
||||
|
||||
|
||||
# $Log: stereo.tcl,v $
|
||||
# Revision 1.4 2004/12/21 05:28:39 gregcouch
|
||||
# Apply outstanding patches and Mac OS X support.
|
||||
#
|
||||
# Revision 1.3 2001/12/20 13:59:31 beskow
|
||||
# Improved error-handling in togl.c in case of window creation failure
|
||||
# Added pkgIndex target to makefile
|
||||
# Updated documentation to reflect stubs-interface (Togl.html + new README.stubs)
|
||||
# Added tk8.4a3 headers
|
||||
# Removed obsolete Tk internal headers
|
||||
#
|
||||
# Revision 1.2 2001/01/29 18:11:53 brianp
|
||||
# Jonas Beskow's changes to use Tcl/Tk stub interface
|
||||
#
|
||||
# Revision 1.1 1997/10/01 02:53:12 brianp
|
||||
# Initial revision
|
||||
#
|
||||
#
|
||||
# Revision 1.1 1997/9/28 18:54:46 Ben Evans
|
||||
# Initial revision. Based on double.tcl
|
||||
#
|
||||
|
||||
|
||||
# An Tk/OpenGL widget demo with two windows, one single buffered and the
|
||||
# other double buffered.
|
||||
|
||||
load [file dirname [info script]]/stereo[info sharedlibextension]
|
||||
|
||||
proc setup {} {
|
||||
global scale
|
||||
set scale 1.0
|
||||
wm title . "Full Screen Stereo Buffering"
|
||||
|
||||
frame .f1
|
||||
togl .f1.o1 -width 200 -height 200 -rgba true -stereo true -double true -depth true -ident "stereo buffer"
|
||||
|
||||
scale .sx -label {X Axis} -from 0 -to 360 -command {setAngle x} -orient horizontal
|
||||
scale .sy -label {Y Axis} -from 0 -to 360 -command {setAngle y} -orient horizontal
|
||||
button .btn -text Quit -command exit
|
||||
|
||||
bind .f1.o1 <B1-Motion> {
|
||||
motion_event [lindex [%W config -width] 4] \
|
||||
[lindex [%W config -height] 4] \
|
||||
%x %y
|
||||
}
|
||||
|
||||
bind .f1.o1 <ButtonPress-2> {
|
||||
set startx %x
|
||||
set starty %y
|
||||
set scale0 $scale
|
||||
}
|
||||
|
||||
bind .f1.o1 <B1-B2-Motion> {
|
||||
set q [ expr ($starty - %y) / 400.0 ]
|
||||
set scale [expr $scale0 * exp($q)]
|
||||
.f1.o1 scale $scale
|
||||
}
|
||||
|
||||
pack .f1.o1 -side left -padx 3 -pady 3 -fill both -expand t
|
||||
pack .f1 -fill both -expand t
|
||||
pack .sx -fill x
|
||||
pack .sy -fill x
|
||||
pack .btn -fill x
|
||||
|
||||
if {[string first $::tcl_platform(os) IRIX] != -1} {
|
||||
puts "use /usr/gfx/setmon -n 60 to reset display and /usr/gfx/setmon -n STR_RECT to put in display in stereo mode"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
# This is called when mouse button 1 is pressed and moved in either of
|
||||
# the OpenGL windows.
|
||||
proc motion_event { width height x y } {
|
||||
.f1.o1 setXrot [expr 360.0 * $y / $height]
|
||||
.f1.o1 setYrot [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 setAngle {axis value} {
|
||||
global xAngle yAngle zAngle
|
||||
|
||||
switch -exact $axis {
|
||||
x {.f1.o1 setXrot $value}
|
||||
y {.f1.o1 setYrot $value}
|
||||
}
|
||||
}
|
||||
|
||||
# Execution starts here!
|
||||
setup
|
26
ng/Togl-1.7/tclconfig/README.txt
Normal file
26
ng/Togl-1.7/tclconfig/README.txt
Normal file
@ -0,0 +1,26 @@
|
||||
These files comprise the basic building blocks for a Tcl Extension
|
||||
Architecture (TEA) extension. For more information on TEA see:
|
||||
|
||||
http://www.tcl.tk/doc/tea/
|
||||
|
||||
This package is part of the Tcl project at SourceForge, and latest
|
||||
sources should be available there:
|
||||
|
||||
http://tcl.sourceforge.net/
|
||||
|
||||
This package is a freely available open source package. You can do
|
||||
virtually anything you like with it, such as modifying it, redistributing
|
||||
it, and selling it either in whole or in part.
|
||||
|
||||
CONTENTS
|
||||
========
|
||||
The following is a short description of the files you will find in
|
||||
the sample extension.
|
||||
|
||||
README.txt This file
|
||||
|
||||
install-sh Program used for copying binaries and script files
|
||||
to their install locations.
|
||||
|
||||
tcl.m4 Collection of Tcl autoconf macros. Included by a package's
|
||||
aclocal.m4 to define TEA_* macros.
|
119
ng/Togl-1.7/tclconfig/install-sh
Normal file
119
ng/Togl-1.7/tclconfig/install-sh
Normal 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
|
3959
ng/Togl-1.7/tclconfig/tcl.m4
Normal file
3959
ng/Togl-1.7/tclconfig/tcl.m4
Normal file
File diff suppressed because it is too large
Load Diff
608
ng/Togl-1.7/texture.c
Normal file
608
ng/Togl-1.7/texture.c
Normal file
@ -0,0 +1,608 @@
|
||||
/* $Id: texture.c,v 1.10 2005/04/23 07:49:14 gregcouch Exp $ */
|
||||
|
||||
/*
|
||||
* Togl - a Tk OpenGL widget
|
||||
* Copyright (C) 1996-1997 Brian Paul and Ben Bederson
|
||||
* See the LICENSE file for copyright details.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* An example Togl program demonstrating texture mapping
|
||||
*/
|
||||
|
||||
|
||||
#include "togl.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if defined(TOGL_AGL) || defined(TOGL_AGL_CLASSIC)
|
||||
# include <OpenGL/glu.h>
|
||||
#else
|
||||
# include <GL/glu.h>
|
||||
#endif
|
||||
#include "image.h"
|
||||
|
||||
|
||||
/*
|
||||
* The following variable is a special hack that is needed in order for
|
||||
* Sun shared libraries to be used for Tcl.
|
||||
*/
|
||||
#ifdef SUN
|
||||
extern int matherr();
|
||||
int *tclDummyMathPtr = (int *) matherr;
|
||||
#endif
|
||||
|
||||
#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 image = CHECKER;
|
||||
static GLfloat coord_scale = 1.0;
|
||||
static GLfloat xrot = 0.0;
|
||||
static GLfloat yrot = 0.0;
|
||||
static GLfloat scale = 1.0;
|
||||
|
||||
static GLint width, height;
|
||||
|
||||
static GLboolean blend = GL_FALSE;
|
||||
|
||||
|
||||
/*
|
||||
* Load a texture image. n is one of CHECKER, FACE or TREE.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
void
|
||||
create_cb(Togl *togl)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
void
|
||||
reshape_cb(Togl *togl)
|
||||
{
|
||||
width = Togl_Width(togl);
|
||||
height = Togl_Height(togl);
|
||||
|
||||
glViewport(0, 0, width, height);
|
||||
|
||||
}
|
||||
|
||||
|
||||
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.
|
||||
*/
|
||||
void
|
||||
display_cb(Togl *togl)
|
||||
{
|
||||
float aspect = (float) width / (float) height;
|
||||
|
||||
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.0, 0.3);
|
||||
glVertex2f(-1.0, -1.0);
|
||||
glColor3f(0.0, 0.0, 0.3);
|
||||
glVertex2f(1.0, -1.0);
|
||||
glColor3f(0.0, 0.0, 0.9);
|
||||
glVertex2f(1.0, 1.0);
|
||||
glColor3f(0.0, 0.0, 0.9);
|
||||
glVertex2f(-1.0, 1.0);
|
||||
glEnd();
|
||||
|
||||
/* draw textured object */
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-aspect, aspect, -1.0, 1.0, 2.0, 10.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -5.0);
|
||||
glScalef(scale, scale, scale);
|
||||
glRotatef(yrot, 0.0, 1.0, 0.0);
|
||||
glRotatef(xrot, 1.0, 0.0, 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, 0.0);
|
||||
glVertex2f(-1.0, -1.0);
|
||||
glTexCoord2f(coord_scale, 0.0);
|
||||
glVertex2f(1.0, -1.0);
|
||||
glTexCoord2f(coord_scale, coord_scale);
|
||||
glVertex2f(1.0, 1.0);
|
||||
glTexCoord2f(0.0, coord_scale);
|
||||
glVertex2f(-1.0, 1.0);
|
||||
glEnd();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
Togl_SwapBuffers(togl);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called when a magnification filter radio button is pressed.
|
||||
*/
|
||||
int
|
||||
magfilter_cb(Togl *togl, int argc, CONST84 char *argv[])
|
||||
{
|
||||
Tcl_Interp *interp = Togl_Interp(togl);
|
||||
|
||||
if (strcmp(argv[2], "GL_NEAREST") == 0) {
|
||||
magfilter = GL_NEAREST;
|
||||
} else if (strcmp(argv[2], "GL_LINEAR") == 0) {
|
||||
magfilter = GL_LINEAR;
|
||||
} else {
|
||||
Tcl_SetResult(interp, "unknown magnification filter type", TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magfilter);
|
||||
Togl_PostRedisplay(togl);
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called when a minification filter radio button is pressed.
|
||||
*/
|
||||
int
|
||||
minfilter_cb(Togl *togl, int argc, CONST84 char *argv[])
|
||||
{
|
||||
Tcl_Interp *interp = Togl_Interp(togl);
|
||||
|
||||
if (strcmp(argv[2], "GL_NEAREST") == 0) {
|
||||
minfilter = GL_NEAREST;
|
||||
} else if (strcmp(argv[2], "GL_LINEAR") == 0) {
|
||||
minfilter = GL_LINEAR;
|
||||
} else if (strcmp(argv[2], "GL_NEAREST_MIPMAP_NEAREST") == 0) {
|
||||
minfilter = GL_NEAREST_MIPMAP_NEAREST;
|
||||
} else if (strcmp(argv[2], "GL_LINEAR_MIPMAP_NEAREST") == 0) {
|
||||
minfilter = GL_LINEAR_MIPMAP_NEAREST;
|
||||
} else if (strcmp(argv[2], "GL_NEAREST_MIPMAP_LINEAR") == 0) {
|
||||
minfilter = GL_NEAREST_MIPMAP_LINEAR;
|
||||
} else if (strcmp(argv[2], "GL_LINEAR_MIPMAP_LINEAR") == 0) {
|
||||
minfilter = GL_LINEAR_MIPMAP_LINEAR;
|
||||
} else {
|
||||
Tcl_SetResult(interp, "unknown minification filter type", TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minfilter);
|
||||
Togl_PostRedisplay(togl);
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
xrot_cb(Togl *togl, int argc, CONST84 char *argv[])
|
||||
{
|
||||
Tcl_Interp *interp = Togl_Interp(togl);
|
||||
|
||||
/* error checking */
|
||||
if (argc != 3) {
|
||||
Tcl_SetResult(interp,
|
||||
"wrong # args: should be \"pathName setXrot ?angle?\"",
|
||||
TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
xrot = atof(argv[2]);
|
||||
|
||||
Togl_PostRedisplay(togl);
|
||||
|
||||
/* Let result string equal value */
|
||||
strcpy(interp->result, argv[2]);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
yrot_cb(Togl *togl, int argc, CONST84 char *argv[])
|
||||
{
|
||||
Tcl_Interp *interp = Togl_Interp(togl);
|
||||
|
||||
/* error checking */
|
||||
if (argc != 3) {
|
||||
Tcl_SetResult(interp,
|
||||
"wrong # args: should be \"pathName setYrot ?angle?\"",
|
||||
TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
yrot = atof(argv[2]);
|
||||
|
||||
Togl_PostRedisplay(togl);
|
||||
|
||||
/* Let result string equal value */
|
||||
strcpy(interp->result, argv[2]);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
scale_cb(Togl *togl, int argc, CONST84 char *argv[])
|
||||
{
|
||||
Tcl_Interp *interp = Togl_Interp(togl);
|
||||
|
||||
/* error checking */
|
||||
if (argc != 3) {
|
||||
Tcl_SetResult(interp,
|
||||
"wrong # args: should be \"pathName scale ?value?\"",
|
||||
TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
scale = atof(argv[2]);
|
||||
|
||||
Togl_PostRedisplay(togl);
|
||||
|
||||
/* Let result string equal value */
|
||||
strcpy(interp->result, argv[2]);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called when S texture coordinate wrapping is changed.
|
||||
*/
|
||||
int
|
||||
swrap_cb(Togl *togl, int argc, CONST84 char *argv[])
|
||||
{
|
||||
Tcl_Interp *interp = Togl_Interp(togl);
|
||||
|
||||
/* error checking */
|
||||
if (argc != 3) {
|
||||
Tcl_SetResult(interp,
|
||||
"wrong # args: should be \"pathName swrap ?mode?\"",
|
||||
TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if (strcmp(argv[2], "GL_CLAMP") == 0) {
|
||||
swrap = GL_CLAMP;
|
||||
} else if (strcmp(argv[2], "GL_REPEAT") == 0) {
|
||||
swrap = GL_REPEAT;
|
||||
} else {
|
||||
Tcl_SetResult(interp, "unknown wrap value", TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, swrap);
|
||||
Togl_PostRedisplay(togl);
|
||||
|
||||
/* Let result string equal value */
|
||||
strcpy(interp->result, argv[2]);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called when T texture coordinate wrapping is changed.
|
||||
*/
|
||||
int
|
||||
twrap_cb(Togl *togl, int argc, CONST84 char *argv[])
|
||||
{
|
||||
Tcl_Interp *interp = Togl_Interp(togl);
|
||||
|
||||
/* error checking */
|
||||
if (argc != 3) {
|
||||
Tcl_SetResult(interp,
|
||||
"wrong # args: should be \"pathName twrap ?mode?\"",
|
||||
TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if (strcmp(argv[2], "GL_CLAMP") == 0) {
|
||||
twrap = GL_CLAMP;
|
||||
} else if (strcmp(argv[2], "GL_REPEAT") == 0) {
|
||||
twrap = GL_REPEAT;
|
||||
} else {
|
||||
Tcl_SetResult(interp, "unknown wrap value", TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, twrap);
|
||||
Togl_PostRedisplay(togl);
|
||||
|
||||
/* Let result string equal value */
|
||||
strcpy(interp->result, argv[2]);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called when the texture environment mode is changed.
|
||||
*/
|
||||
int
|
||||
envmode_cb(Togl *togl, int argc, CONST84 char *argv[])
|
||||
{
|
||||
Tcl_Interp *interp = Togl_Interp(togl);
|
||||
|
||||
/* error checking */
|
||||
if (argc != 3) {
|
||||
Tcl_SetResult(interp,
|
||||
"wrong # args: should be \"pathName envmode ?mode?\"",
|
||||
TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if (strcmp(argv[2], "GL_MODULATE") == 0) {
|
||||
envmode = GL_MODULATE;
|
||||
} else if (strcmp(argv[2], "GL_DECAL") == 0) {
|
||||
envmode = GL_DECAL;
|
||||
} else if (strcmp(argv[2], "GL_BLEND") == 0) {
|
||||
envmode = GL_BLEND;
|
||||
} else {
|
||||
Tcl_SetResult(interp, "unknown texture env mode", TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, envmode);
|
||||
Togl_PostRedisplay(togl);
|
||||
|
||||
/* Let result string equal value */
|
||||
strcpy(interp->result, argv[2]);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called when the polygon color is changed.
|
||||
*/
|
||||
int
|
||||
polycolor_cb(Togl *togl, int argc, CONST84 char *argv[])
|
||||
{
|
||||
Tcl_Interp *interp = Togl_Interp(togl);
|
||||
|
||||
/* error checking */
|
||||
if (argc != 5) {
|
||||
Tcl_SetResult(interp,
|
||||
"wrong # args: should be \"pathName polycolor ?r? ?g? ?b?\"",
|
||||
TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
polycolor[0] = atoi(argv[2]);
|
||||
polycolor[1] = atoi(argv[3]);
|
||||
polycolor[2] = atoi(argv[4]);
|
||||
|
||||
Togl_PostRedisplay(togl);
|
||||
|
||||
/* Let result string equal value */
|
||||
strcpy(interp->result, argv[2]);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called when the texture image is to be changed
|
||||
*/
|
||||
int
|
||||
image_cb(Togl *togl, int argc, CONST84 char *argv[])
|
||||
{
|
||||
Tcl_Interp *interp = Togl_Interp(togl);
|
||||
|
||||
/* error checking */
|
||||
if (argc != 3) {
|
||||
Tcl_SetResult(interp,
|
||||
"wrong # args: should be \"pathName image ?name?\"",
|
||||
TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if (strcmp(argv[2], "CHECKER") == 0) {
|
||||
texture_image(CHECKER);
|
||||
} else if (strcmp(argv[2], "FACE") == 0) {
|
||||
texture_image(FACE);
|
||||
} else if (strcmp(argv[2], "TREE") == 0) {
|
||||
texture_image(TREE);
|
||||
} else {
|
||||
Tcl_SetResult(interp, "unknown texture image", TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
Togl_PostRedisplay(togl);
|
||||
|
||||
/* Let result string equal value */
|
||||
strcpy(interp->result, argv[2]);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called when the texture coordinate scale is changed.
|
||||
*/
|
||||
int
|
||||
coord_scale_cb(Togl *togl, int argc, CONST84 char *argv[])
|
||||
{
|
||||
Tcl_Interp *interp = Togl_Interp(togl);
|
||||
float s;
|
||||
|
||||
/* error checking */
|
||||
if (argc != 3) {
|
||||
Tcl_SetResult(interp,
|
||||
"wrong # args: should be \"pathName coord_scale ?scale?\"",
|
||||
TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
s = atof(argv[2]);
|
||||
if (s > 0.0 && s < 10.0) {
|
||||
coord_scale = s;
|
||||
Togl_PostRedisplay(togl);
|
||||
}
|
||||
|
||||
/* Let result string equal value */
|
||||
strcpy(interp->result, argv[2]);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
TOGL_EXTERN int
|
||||
Texture_Init(Tcl_Interp *interp)
|
||||
{
|
||||
/*
|
||||
* Initialize Tcl, Tk, and the Togl widget module.
|
||||
*/
|
||||
#ifdef USE_TCL_STUBS
|
||||
if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_TK_STUBS
|
||||
if (Tk_InitStubs(interp, "8.1", 0) == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Togl_Init(interp) == TCL_ERROR) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Specify the C callback functions for widget creation, display,
|
||||
* and reshape.
|
||||
*/
|
||||
Togl_CreateFunc(create_cb);
|
||||
Togl_DisplayFunc(display_cb);
|
||||
Togl_ReshapeFunc(reshape_cb);
|
||||
|
||||
/*
|
||||
* Make a new Togl widget command so the Tcl code can set a C variable.
|
||||
*/
|
||||
Togl_CreateCommand("min_filter", minfilter_cb);
|
||||
Togl_CreateCommand("mag_filter", magfilter_cb);
|
||||
Togl_CreateCommand("xrot", xrot_cb);
|
||||
Togl_CreateCommand("yrot", yrot_cb);
|
||||
Togl_CreateCommand("scale", scale_cb);
|
||||
Togl_CreateCommand("swrap", swrap_cb);
|
||||
Togl_CreateCommand("twrap", twrap_cb);
|
||||
Togl_CreateCommand("envmode", envmode_cb);
|
||||
Togl_CreateCommand("polycolor", polycolor_cb);
|
||||
Togl_CreateCommand("image", image_cb);
|
||||
Togl_CreateCommand("coord_scale", coord_scale_cb);
|
||||
|
||||
/*
|
||||
* Call Tcl_CreateCommand for application-specific commands, if
|
||||
* they weren't already created by the init procedures called above.
|
||||
*/
|
||||
|
||||
return TCL_OK;
|
||||
}
|
283
ng/Togl-1.7/texture.tcl
Normal file
283
ng/Togl-1.7/texture.tcl
Normal file
@ -0,0 +1,283 @@
|
||||
#!/bin/sh
|
||||
# the next line restarts using wish \
|
||||
exec wish "$0" "$@"
|
||||
|
||||
# $Id: texture.tcl,v 1.5 2001/12/20 13:59:31 beskow Exp $
|
||||
|
||||
# Togl - a Tk OpenGL widget
|
||||
# Copyright (C) 1996 Brian Paul and Ben Bederson
|
||||
# See the LICENSE file for copyright details.
|
||||
|
||||
|
||||
# $Log: texture.tcl,v $
|
||||
# Revision 1.5 2001/12/20 13:59:31 beskow
|
||||
# Improved error-handling in togl.c in case of window creation failure
|
||||
# Added pkgIndex target to makefile
|
||||
# Updated documentation to reflect stubs-interface (Togl.html + new README.stubs)
|
||||
# Added tk8.4a3 headers
|
||||
# Removed obsolete Tk internal headers
|
||||
#
|
||||
# Revision 1.4 2001/01/29 18:11:53 brianp
|
||||
# Jonas Beskow's changes to use Tcl/Tk stub interface
|
||||
#
|
||||
# Revision 1.3 1998/01/24 14:05:50 brianp
|
||||
# added quit button (Ben Bederson)
|
||||
#
|
||||
# Revision 1.2 1997/09/30 23:54:46 brianp
|
||||
# new layout
|
||||
#
|
||||
# Revision 1.1 1996/10/23 23:18:36 brianp
|
||||
# Initial revision
|
||||
#
|
||||
|
||||
|
||||
# Togl texture map demo
|
||||
|
||||
load [file dirname [info script]]/texture[info sharedlibextension]
|
||||
|
||||
|
||||
# Called magnification filter changes
|
||||
proc new_magfilter {} {
|
||||
global magfilter
|
||||
.f1.view mag_filter $magfilter
|
||||
}
|
||||
|
||||
|
||||
# Called minification filter changes
|
||||
proc new_minfilter {} {
|
||||
global minfilter
|
||||
.f1.view min_filter $minfilter
|
||||
}
|
||||
|
||||
|
||||
# Called when texture image radio button changes
|
||||
proc new_image {} {
|
||||
global teximage
|
||||
.f1.view image $teximage
|
||||
}
|
||||
|
||||
|
||||
# Called when texture S wrap button changes
|
||||
proc new_swrap {} {
|
||||
global swrap
|
||||
.f1.view swrap $swrap
|
||||
}
|
||||
|
||||
|
||||
# Called when texture T wrap button changes
|
||||
proc new_twrap {} {
|
||||
global twrap
|
||||
.f1.view twrap $twrap
|
||||
}
|
||||
|
||||
|
||||
# Called when texture environment radio button selected
|
||||
proc new_env {} {
|
||||
global envmode
|
||||
.f1.view envmode $envmode
|
||||
}
|
||||
|
||||
|
||||
# Called when polygon color sliders change
|
||||
proc new_color { foo } {
|
||||
global poly_red poly_green poly_blue
|
||||
.f1.view polycolor $poly_red $poly_green $poly_blue
|
||||
}
|
||||
|
||||
|
||||
proc new_coord_scale { name element op } {
|
||||
global coord_scale
|
||||
.f1.view coord_scale $coord_scale
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
# Make the widgets
|
||||
proc setup {} {
|
||||
global magfilter
|
||||
global minfilter
|
||||
global teximage
|
||||
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 scale scale0
|
||||
|
||||
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
|
||||
|
||||
|
||||
### 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 new_magfilter
|
||||
radiobutton .f1.filter.mag.linear -text GL_LINEAR -anchor w -variable magfilter -value GL_LINEAR -command 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 new_minfilter
|
||||
radiobutton .f1.filter.min.linear -text GL_LINEAR -anchor w -variable minfilter -value GL_LINEAR -command new_minfilter
|
||||
radiobutton .f1.filter.min.nearest_mipmap_nearest -text GL_NEAREST_MIPMAP_NEAREST -anchor w -variable minfilter -value GL_NEAREST_MIPMAP_NEAREST -command new_minfilter
|
||||
radiobutton .f1.filter.min.linear_mipmap_nearest -text GL_LINEAR_MIPMAP_NEAREST -anchor w -variable minfilter -value GL_LINEAR_MIPMAP_NEAREST -command new_minfilter
|
||||
radiobutton .f1.filter.min.nearest_mipmap_linear -text GL_NEAREST_MIPMAP_LINEAR -anchor w -variable minfilter -value GL_NEAREST_MIPMAP_LINEAR -command new_minfilter
|
||||
radiobutton .f1.filter.min.linear_mipmap_linear -text GL_LINEAR_MIPMAP_LINEAR -anchor w -variable minfilter -value GL_LINEAR_MIPMAP_LINEAR -command 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 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 new_swrap
|
||||
radiobutton .f2.coord.s.clamp -text "GL_CLAMP" -anchor w -variable swrap -value GL_CLAMP -command 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 new_twrap
|
||||
radiobutton .f2.coord.t.clamp -text "GL_CLAMP" -anchor w -variable twrap -value GL_CLAMP -command 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 teximage -value CHECKER -command new_image
|
||||
radiobutton .f2.env.image.tree -text "Tree" -anchor w -variable teximage -value TREE -command new_image
|
||||
radiobutton .f2.env.image.face -text "Face" -anchor w -variable teximage -value FACE -command 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 new_env
|
||||
radiobutton .f2.env.decal -text "GL_DECAL" -anchor w -variable envmode -value GL_DECAL -command new_env
|
||||
radiobutton .f2.env.blend -text "GL_BLEND" -anchor w -variable envmode -value GL_BLEND -command 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 new_color
|
||||
scale .f2.color.green -label Green -from 0 -to 255 -orient horizontal -variable poly_green -command new_color
|
||||
scale .f2.color.blue -label Blue -from 0 -to 255 -orient horizontal -variable poly_blue -command 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 .btn -text Quit -command exit
|
||||
pack .btn -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 ]
|
||||
.f1.view yrot $xangle
|
||||
.f1.view xrot $yangle
|
||||
}
|
||||
|
||||
bind .f1.view <ButtonPress-2> {
|
||||
set startx %x
|
||||
set starty %y
|
||||
set scale0 $scale
|
||||
}
|
||||
|
||||
bind .f1.view <B2-Motion> {
|
||||
set q [ expr ($starty - %y) / 400.0 ]
|
||||
set scale [expr $scale0 * exp($q)]
|
||||
.f1.view scale $scale
|
||||
}
|
||||
|
||||
# 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 teximage 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 scale 1.0
|
||||
}
|
||||
|
||||
|
||||
# Execution starts here!
|
||||
setup
|
||||
|
35
ng/Togl-1.7/tkMacOSX.h
Normal file
35
ng/Togl-1.7/tkMacOSX.h
Normal file
@ -0,0 +1,35 @@
|
||||
/* This file isn't installed by default */
|
||||
/*
|
||||
* tkMacOSXInt.h --
|
||||
*
|
||||
* Declarations of Macintosh specific exported variables and procedures.
|
||||
*
|
||||
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
|
||||
* Copyright 2001, Apple Computer, Inc.
|
||||
*
|
||||
* See the file "license.terms" for information on usage and redistribution
|
||||
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
*
|
||||
* RCS: @(#) $Id: tkMacOSX.h,v 1.1 2005/04/22 02:00:07 gregcouch Exp $
|
||||
*/
|
||||
|
||||
#ifndef _TKMAC
|
||||
#define _TKMAC
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
#include "tkInt.h"
|
||||
|
||||
/*
|
||||
* Structures and function types for handling Netscape-type in process
|
||||
* embedding where Tk does not control the top-level
|
||||
*/
|
||||
|
||||
typedef int (Tk_MacOSXEmbedRegisterWinProc) (int winID, Tk_Window window);
|
||||
typedef GWorldPtr (Tk_MacOSXEmbedGetGrafPortProc) (Tk_Window window);
|
||||
typedef int (Tk_MacOSXEmbedMakeContainerExistProc) (Tk_Window window);
|
||||
typedef void (Tk_MacOSXEmbedGetClipProc) (Tk_Window window, RgnHandle rgn);
|
||||
typedef void (Tk_MacOSXEmbedGetOffsetInParentProc) (Tk_Window window, Point *ulCorner);
|
||||
|
||||
#include "tkPlatDecls.h"
|
||||
|
||||
#endif /* _TKMAC */
|
4033
ng/Togl-1.7/togl.c
Normal file
4033
ng/Togl-1.7/togl.c
Normal file
File diff suppressed because it is too large
Load Diff
242
ng/Togl-1.7/togl.h
Normal file
242
ng/Togl-1.7/togl.h
Normal file
@ -0,0 +1,242 @@
|
||||
/* $Id: togl.h,v 1.28 2005/10/27 07:45:48 gregcouch Exp $ */
|
||||
|
||||
/* vi:set sw=4: */
|
||||
|
||||
/*
|
||||
* Togl - a Tk OpenGL widget
|
||||
*
|
||||
* Copyright (C) 1996-1998 Brian Paul and Ben Bederson
|
||||
* 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
|
||||
|
||||
# ifdef _WIN32
|
||||
# define TOGL_EXTERN __declspec(dllexport) extern
|
||||
# else
|
||||
# define TOGL_EXTERN extern
|
||||
# endif /* _WIN32 */
|
||||
|
||||
# ifdef TOGL_AGL_CLASSIC
|
||||
# ifndef MAC_TCL
|
||||
# define MAC_TCL 1
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifdef TOGL_AGL
|
||||
# ifndef MAC_OSX_TCL
|
||||
# define MAC_OSX_TCL 1
|
||||
# endif
|
||||
# ifndef MAC_OSX_TK
|
||||
# define MAC_OSX_TK 1
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# include <tcl.h>
|
||||
# include <tk.h>
|
||||
# if defined(TOGL_AGL) || defined(TOGL_AGL_CLASSIC)
|
||||
# include <OpenGL/gl.h>
|
||||
# else
|
||||
# include <GL/gl.h>
|
||||
# endif
|
||||
|
||||
# ifdef __sgi
|
||||
# include <GL/glx.h>
|
||||
# include <X11/extensions/SGIStereo.h>
|
||||
# endif
|
||||
|
||||
# ifndef CONST84
|
||||
# define CONST84
|
||||
# endif
|
||||
|
||||
# ifndef NULL
|
||||
# define NULL 0
|
||||
# endif
|
||||
|
||||
# ifndef TOGL_USE_FONTS
|
||||
# define TOGL_USE_FONTS 1 /* needed for demos */
|
||||
# endif
|
||||
|
||||
# ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
# endif
|
||||
|
||||
# define TOGL_VERSION "1.7"
|
||||
# define TOGL_MAJOR_VERSION 1
|
||||
# define TOGL_MINOR_VERSION 7
|
||||
|
||||
/*
|
||||
* "Standard" fonts which can be specified to Togl_LoadBitmapFont()
|
||||
*/
|
||||
# define TOGL_BITMAP_8_BY_13 ((char *) 1)
|
||||
# define TOGL_BITMAP_9_BY_15 ((char *) 2)
|
||||
# define TOGL_BITMAP_TIMES_ROMAN_10 ((char *) 3)
|
||||
# define TOGL_BITMAP_TIMES_ROMAN_24 ((char *) 4)
|
||||
# define TOGL_BITMAP_HELVETICA_10 ((char *) 5)
|
||||
# define TOGL_BITMAP_HELVETICA_12 ((char *) 6)
|
||||
# define TOGL_BITMAP_HELVETICA_18 ((char *) 7)
|
||||
|
||||
/*
|
||||
* Normal and overlay plane constants
|
||||
*/
|
||||
# define TOGL_NORMAL 1
|
||||
# define TOGL_OVERLAY 2
|
||||
|
||||
struct Togl;
|
||||
typedef struct Togl Togl;
|
||||
|
||||
typedef void (Togl_Callback) (Togl *togl);
|
||||
typedef int (Togl_CmdProc) (Togl *togl, int argc, CONST84 char *argv[]);
|
||||
|
||||
TOGL_EXTERN int Togl_Init(Tcl_Interp *interp);
|
||||
|
||||
/*
|
||||
* Default/initial callback setup functions
|
||||
*/
|
||||
|
||||
TOGL_EXTERN void Togl_CreateFunc(Togl_Callback *proc);
|
||||
TOGL_EXTERN void Togl_DisplayFunc(Togl_Callback *proc);
|
||||
TOGL_EXTERN void Togl_ReshapeFunc(Togl_Callback *proc);
|
||||
TOGL_EXTERN void Togl_DestroyFunc(Togl_Callback *proc);
|
||||
TOGL_EXTERN void Togl_TimerFunc(Togl_Callback *proc);
|
||||
TOGL_EXTERN void Togl_ResetDefaultCallbacks(void);
|
||||
|
||||
/*
|
||||
* Change callbacks for existing widget
|
||||
*/
|
||||
|
||||
TOGL_EXTERN void Togl_SetCreateFunc(Togl *togl, Togl_Callback *proc);
|
||||
TOGL_EXTERN void Togl_SetDisplayFunc(Togl *togl, Togl_Callback *proc);
|
||||
TOGL_EXTERN void Togl_SetReshapeFunc(Togl *togl, Togl_Callback *proc);
|
||||
TOGL_EXTERN void Togl_SetDestroyFunc(Togl *togl, Togl_Callback *proc);
|
||||
TOGL_EXTERN void Togl_SetTimerFunc(Togl *togl, Togl_Callback *proc);
|
||||
|
||||
/*
|
||||
* Miscellaneous
|
||||
*/
|
||||
|
||||
TOGL_EXTERN int Togl_Configure(Tcl_Interp *interp, Togl *togl,
|
||||
int argc, const char *argv[], int flags);
|
||||
TOGL_EXTERN void Togl_MakeCurrent(const Togl *togl);
|
||||
TOGL_EXTERN void Togl_CreateCommand(char *cmd_name, Togl_CmdProc *cmd_proc);
|
||||
TOGL_EXTERN void Togl_PostRedisplay(Togl *togl);
|
||||
TOGL_EXTERN void Togl_SwapBuffers(const Togl *togl);
|
||||
|
||||
/*
|
||||
* Query functions
|
||||
*/
|
||||
|
||||
TOGL_EXTERN const char *Togl_Ident(const Togl *togl);
|
||||
TOGL_EXTERN int Togl_Width(const Togl *togl);
|
||||
TOGL_EXTERN int Togl_Height(const Togl *togl);
|
||||
TOGL_EXTERN Tcl_Interp *Togl_Interp(const Togl *togl);
|
||||
TOGL_EXTERN Tk_Window Togl_TkWin(const Togl *togl);
|
||||
|
||||
/*
|
||||
* Color Index mode
|
||||
*/
|
||||
|
||||
TOGL_EXTERN unsigned long Togl_AllocColor(const Togl *togl, float red,
|
||||
float green, float blue);
|
||||
TOGL_EXTERN void Togl_FreeColor(const Togl *togl, unsigned long index);
|
||||
TOGL_EXTERN void Togl_SetColor(const Togl *togl, unsigned long index,
|
||||
float red, float green, float blue);
|
||||
|
||||
# if TOGL_USE_FONTS == 1
|
||||
/*
|
||||
* Bitmap fonts
|
||||
*/
|
||||
|
||||
TOGL_EXTERN GLuint Togl_LoadBitmapFont(const Togl *togl, const char *fontname);
|
||||
TOGL_EXTERN void Togl_UnloadBitmapFont(const Togl *togl, GLuint fontbase);
|
||||
|
||||
# endif
|
||||
/*
|
||||
* Overlay functions
|
||||
*/
|
||||
|
||||
TOGL_EXTERN void Togl_UseLayer(Togl *togl, int layer);
|
||||
TOGL_EXTERN void Togl_ShowOverlay(Togl *togl);
|
||||
TOGL_EXTERN void Togl_HideOverlay(Togl *togl);
|
||||
TOGL_EXTERN void Togl_PostOverlayRedisplay(Togl *togl);
|
||||
TOGL_EXTERN void Togl_OverlayDisplayFunc(Togl_Callback *proc);
|
||||
TOGL_EXTERN int Togl_ExistsOverlay(const Togl *togl);
|
||||
TOGL_EXTERN int Togl_GetOverlayTransparentValue(const Togl *togl);
|
||||
TOGL_EXTERN int Togl_IsMappedOverlay(const Togl *togl);
|
||||
TOGL_EXTERN unsigned long Togl_AllocColorOverlay(const Togl *togl,
|
||||
float red, float green, float blue);
|
||||
TOGL_EXTERN void Togl_FreeColorOverlay(const Togl *togl, unsigned long index);
|
||||
|
||||
/*
|
||||
* User client data
|
||||
*/
|
||||
|
||||
TOGL_EXTERN void Togl_ClientData(ClientData clientData);
|
||||
TOGL_EXTERN ClientData Togl_GetClientData(const Togl *togl);
|
||||
TOGL_EXTERN void Togl_SetClientData(Togl *togl, ClientData clientData);
|
||||
|
||||
# ifdef TOGL_X11
|
||||
/*
|
||||
* X11-only commands.
|
||||
* Contributed by Miguel A. De Riera Pasenau (miguel@DALILA.UPC.ES)
|
||||
*/
|
||||
|
||||
TOGL_EXTERN Display *Togl_Display(const Togl *togl);
|
||||
TOGL_EXTERN Screen *Togl_Screen(const Togl *togl);
|
||||
TOGL_EXTERN int Togl_ScreenNumber(const Togl *togl);
|
||||
TOGL_EXTERN Colormap Togl_Colormap(const Togl *togl);
|
||||
|
||||
# endif
|
||||
# ifdef __sgi
|
||||
/*
|
||||
* SGI stereo-only commands.
|
||||
* Contributed by Ben Evans (Ben.Evans@anusf.anu.edu.au)
|
||||
*/
|
||||
|
||||
TOGL_EXTERN void Togl_OldStereoDrawBuffer(GLenum mode);
|
||||
TOGL_EXTERN void Togl_OldStereoClear(GLbitfield mask);
|
||||
# endif
|
||||
|
||||
TOGL_EXTERN void Togl_StereoFrustum(GLfloat left, GLfloat right, GLfloat bottom,
|
||||
GLfloat top, GLfloat near, GLfloat far, GLfloat eyeDist,
|
||||
GLfloat eyeOffset);
|
||||
|
||||
/*
|
||||
* Generate EPS file.
|
||||
* Contributed by Miguel A. De Riera Pasenau (miguel@DALILA.UPC.ES)
|
||||
*/
|
||||
|
||||
TOGL_EXTERN int Togl_DumpToEpsFile(const Togl *togl, const char *filename,
|
||||
int inColor, void (*user_redraw) (const Togl *));
|
||||
|
||||
# ifdef TOGL_AGL_CLASSIC
|
||||
/*
|
||||
* Mac-specific setup functions
|
||||
*/
|
||||
extern int Togl_MacInit(void);
|
||||
extern int Togl_MacSetupMainInterp(Tcl_Interp *interp);
|
||||
# endif
|
||||
|
||||
# ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
# endif
|
||||
|
||||
|
||||
#endif
|
7
ng/Togl-1.7/togl_ws.h.in
Normal file
7
ng/Togl-1.7/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
|
BIN
ng/Togl-1.7/tree2.rgba
Normal file
BIN
ng/Togl-1.7/tree2.rgba
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user