GLUT for OS/2 (Evgeny Kotsuba)
This commit is contained in:
parent
8fa507592b
commit
225517aff0
|
@ -0,0 +1,420 @@
|
|||
# Makefile
|
||||
# Created by IBM WorkFrame/2 MakeMake at 12:46:25 on 3 June 2003
|
||||
#
|
||||
# The actions included in this make file are:
|
||||
# Compile::C++ Compiler
|
||||
# Link::Linker
|
||||
# Lib::Import Lib
|
||||
|
||||
.SUFFIXES:
|
||||
|
||||
.SUFFIXES: \
|
||||
.LIB .cpp .dll .obj
|
||||
|
||||
.cpp.obj:
|
||||
@echo " Compile::C++ Compiler "
|
||||
icc.exe /I..\ /I..\X86 /I..\GL /I..\swrast /I..\swrast_setup /Ss /Wcmpcndcnscnvcpydclenuextgeninilanobsordparporppcprorearettrdtruund /Tx /O /Gm /Ge- /G5 /Gf /Gi /Oi /C %s
|
||||
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm}.cpp.obj:
|
||||
@echo " Compile::C++ Compiler "
|
||||
icc.exe /I..\ /I..\X86 /I..\GL /I..\swrast /I..\swrast_setup /Ss /Wcmpcndcnscnvcpydclenuextgeninilanobsordparporppcprorearettrdtruund /Tx /O /Gm /Ge- /G5 /Gf /Gi /Oi /C %s
|
||||
|
||||
.dll.LIB:
|
||||
@echo " Lib::Import Lib "
|
||||
implib.exe %|dpfF.LIB %s
|
||||
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm}.dll.LIB:
|
||||
@echo " Lib::Import Lib "
|
||||
implib.exe %|dpfF.LIB %s
|
||||
|
||||
all: \
|
||||
.\libGlut.LIB
|
||||
|
||||
.\libGlut.dll: \
|
||||
.\os2_winproc.obj \
|
||||
.\WarpWin.obj \
|
||||
.\glutOverlay.obj \
|
||||
.\glut_8x13.obj \
|
||||
.\glut_9x15.obj \
|
||||
.\glut_bitmap.obj \
|
||||
.\glut_cindex.obj \
|
||||
.\glut_cmap.obj \
|
||||
.\glut_cursor.obj \
|
||||
.\glut_event.obj \
|
||||
.\glut_ext.obj \
|
||||
.\glut_fullscrn.obj \
|
||||
.\glut_gamemode.obj \
|
||||
.\glut_get.obj \
|
||||
.\glut_hel10.obj \
|
||||
.\glut_hel12.obj \
|
||||
.\glut_hel18.obj \
|
||||
.\glut_init.obj \
|
||||
.\glut_input.obj \
|
||||
.\glut_key.obj \
|
||||
.\glut_keyctrl.obj \
|
||||
.\glut_keyup.obj \
|
||||
.\glut_mesa.obj \
|
||||
.\glut_modifier.obj \
|
||||
.\glut_roman.obj \
|
||||
.\glut_shapes.obj \
|
||||
.\glut_stroke.obj \
|
||||
.\glut_swap.obj \
|
||||
.\glut_teapot.obj \
|
||||
.\glut_tr24.obj \
|
||||
.\glut_util.obj \
|
||||
.\glut_vidresize.obj \
|
||||
.\glut_warp.obj \
|
||||
.\glut_win.obj \
|
||||
.\glut_winmisc.obj \
|
||||
.\os2_glx.obj \
|
||||
.\os2_menu.obj \
|
||||
..\si-glu\libGLU.lib \
|
||||
..\MesaDll\MesaGL2.lib \
|
||||
..\drv\DrvLoad\MesaDrvLoad.lib \
|
||||
{$(LIB)}libGlut.DEF
|
||||
@echo " Link::Linker "
|
||||
icc.exe @<<
|
||||
/B" /dbgpack /exepack:2 /st:200000 /packd /optfunc"
|
||||
/FelibGlut.dll
|
||||
..\si-glu\libGLU.lib
|
||||
..\MesaDll\MesaGL2.lib
|
||||
..\drv\DrvLoad\MesaDrvLoad.lib
|
||||
libGlut.DEF
|
||||
.\os2_winproc.obj
|
||||
.\WarpWin.obj
|
||||
.\glutOverlay.obj
|
||||
.\glut_8x13.obj
|
||||
.\glut_9x15.obj
|
||||
.\glut_bitmap.obj
|
||||
.\glut_cindex.obj
|
||||
.\glut_cmap.obj
|
||||
.\glut_cursor.obj
|
||||
.\glut_event.obj
|
||||
.\glut_ext.obj
|
||||
.\glut_fullscrn.obj
|
||||
.\glut_gamemode.obj
|
||||
.\glut_get.obj
|
||||
.\glut_hel10.obj
|
||||
.\glut_hel12.obj
|
||||
.\glut_hel18.obj
|
||||
.\glut_init.obj
|
||||
.\glut_input.obj
|
||||
.\glut_key.obj
|
||||
.\glut_keyctrl.obj
|
||||
.\glut_keyup.obj
|
||||
.\glut_mesa.obj
|
||||
.\glut_modifier.obj
|
||||
.\glut_roman.obj
|
||||
.\glut_shapes.obj
|
||||
.\glut_stroke.obj
|
||||
.\glut_swap.obj
|
||||
.\glut_teapot.obj
|
||||
.\glut_tr24.obj
|
||||
.\glut_util.obj
|
||||
.\glut_vidresize.obj
|
||||
.\glut_warp.obj
|
||||
.\glut_win.obj
|
||||
.\glut_winmisc.obj
|
||||
.\os2_glx.obj
|
||||
.\os2_menu.obj
|
||||
<<
|
||||
|
||||
.\os2_winproc.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\os2_winproc.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h \
|
||||
gl\os2mesa.h \
|
||||
gl\gl.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}gl_mangle.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}GL/os2_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}os2_config.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}os2mesadef.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}context.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glapi.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}mtypes.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glheader.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}config.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glapitable.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glthread.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}math/m_matrix.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}Trace/tr_context.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}dd.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}conf.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}GL/os2_config.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}GL/glext.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}Xthreads.h
|
||||
|
||||
.\os2_menu.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\os2_menu.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\os2_glx.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\os2_glx.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
gl\os2mesa.h \
|
||||
gl\gl.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}gl_mangle.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}GL/os2_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}os2_config.h
|
||||
|
||||
.\glut_winmisc.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_winmisc.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_win.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_win.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutos2.h \
|
||||
gl\os2mesa.h \
|
||||
gl\gl.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}gl_mangle.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}GL/os2_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}os2_config.h
|
||||
|
||||
.\glut_warp.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_warp.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_vidresize.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_vidresize.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_util.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_util.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_tr24.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_tr24.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutbitmap.h
|
||||
|
||||
.\glut_teapot.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_teapot.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_swap.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_swap.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_stroke.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_stroke.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutstroke.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_shapes.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_shapes.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_roman.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_roman.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutstroke.h
|
||||
|
||||
.\glut_modifier.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_modifier.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_mesa.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_mesa.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_keyup.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_keyup.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_keyctrl.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_keyctrl.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_key.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_key.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_input.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_input.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_init.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_init.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_hel18.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_hel18.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutbitmap.h
|
||||
|
||||
.\glut_hel12.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_hel12.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutbitmap.h
|
||||
|
||||
.\glut_hel10.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_hel10.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutbitmap.h
|
||||
|
||||
.\glut_get.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_get.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_gamemode.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_gamemode.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_fullscrn.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_fullscrn.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_ext.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_ext.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_event.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_event.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_cursor.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_cursor.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_cmap.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_cmap.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}layerutil.h
|
||||
|
||||
.\glut_cindex.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_cindex.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_bitmap.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_bitmap.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutbitmap.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\glut_9x15.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_9x15.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutbitmap.h
|
||||
|
||||
.\glut_8x13.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glut_8x13.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutbitmap.h
|
||||
|
||||
.\glutOverlay.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\glutOverlay.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutint.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutbitmap.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutstroke.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}glutwin32.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_x11.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}win32_glx.h
|
||||
|
||||
.\WarpWin.obj: \
|
||||
G:\EVGEN\MESA5\src-glut.os2pm\WarpWin.cpp \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpWin.h \
|
||||
{G:\EVGEN\MESA5\src-glut.os2pm;..\;..\X86;..\GL;..\swrast;..\swrast_setup;$(INCLUDE);}WarpGL.h
|
||||
|
||||
.\libGlut.LIB: \
|
||||
.\libGlut.dll
|
|
@ -0,0 +1,420 @@
|
|||
/* WarpWin.c */
|
||||
/* glut for Warp */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "WarpWin.h"
|
||||
#include "WarpGL.h"
|
||||
|
||||
#define POKA 0
|
||||
|
||||
/* global variables that must be set for some functions to operate
|
||||
correctly. */
|
||||
HDC XHDC;
|
||||
HWND XHWND;
|
||||
|
||||
|
||||
void
|
||||
XStoreColor(Display* display, Colormap colormap, XColor* color)
|
||||
{
|
||||
/* KLUDGE: set XHDC to 0 if the palette should NOT be realized after
|
||||
setting the color. set XHDC to the correct HDC if it should. */
|
||||
|
||||
LONG pe;
|
||||
ULONG cclr;
|
||||
int r,g,b;
|
||||
/* X11 stores color from 0-65535, Win32 expects them to be 0-256, so
|
||||
twiddle the bits ( / 256). */
|
||||
r = color->red / 256;
|
||||
g = color->green / 256;
|
||||
b = color->blue / 256;
|
||||
pe = LONGFromRGB(r,g,b);
|
||||
/* make sure we use this flag, otherwise the colors might get mapped
|
||||
to another place in the colormap, and when we glIndex() that
|
||||
color, it may have moved (argh!!) */
|
||||
pe |= (PC_NOCOLLAPSE<<24);
|
||||
/* This function changes the entries in a palette. */
|
||||
#if POKA
|
||||
OS2:
|
||||
rc = GpiSetPaletteEntries(colormap,LCOLF_CONSECRGB, color->pixel, 1, &pe);
|
||||
GpiSelectPalette(hps,colormap);
|
||||
WinRealizePalette(hwnd,hps,&cclr);
|
||||
source Win:
|
||||
if (XHDC) {
|
||||
UnrealizeObject(colormap);
|
||||
SelectPalette(XHDC, colormap, FALSE);
|
||||
RealizePalette(XHDC);
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
XSetWindowColormap(Display* display, Window window, Colormap colormap)
|
||||
{
|
||||
#if POKA
|
||||
HDC hdc = GetDC(window);
|
||||
|
||||
/* if the third parameter is FALSE, the logical colormap is copied
|
||||
into the device palette when the application is in the
|
||||
foreground, if it is TRUE, the colors are mapped into the current
|
||||
palette in the best possible way. */
|
||||
SelectPalette(hdc, colormap, FALSE);
|
||||
RealizePalette(hdc);
|
||||
|
||||
/* note that we don't have to release the DC, since our window class
|
||||
uses the WC_OWNDC flag! */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* display, root and visual - don't used at all */
|
||||
Colormap
|
||||
XCreateColormap(Display* display, Window root, Visual* visual, int alloc)
|
||||
{
|
||||
/* KLUDGE: this function needs XHDC to be set to the HDC currently
|
||||
being operated on before it is invoked! */
|
||||
|
||||
HPAL palette;
|
||||
int n;
|
||||
#if POKA
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
LOGPALETTE *logical;
|
||||
|
||||
/* grab the pixel format */
|
||||
memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
|
||||
DescribePixelFormat(XHDC, GetPixelFormat(XHDC),
|
||||
sizeof(PIXELFORMATDESCRIPTOR), &pfd);
|
||||
|
||||
if (!(pfd.dwFlags & PFD_NEED_PALETTE ||
|
||||
pfd.iPixelType == PFD_TYPE_COLORINDEX))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
n = 1 << pfd.cColorBits;
|
||||
|
||||
/* allocate a bunch of memory for the logical palette (assume 256
|
||||
colors in a Win32 palette */
|
||||
logical = (LOGPALETTE*)malloc(sizeof(LOGPALETTE) +
|
||||
sizeof(PALETTEENTRY) * n);
|
||||
memset(logical, 0, sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * n);
|
||||
|
||||
/* set the entries in the logical palette */
|
||||
logical->palVersion = 0x300;
|
||||
logical->palNumEntries = n;
|
||||
|
||||
/* start with a copy of the current system palette */
|
||||
GetSystemPaletteEntries(XHDC, 0, 256, &logical->palPalEntry[0]);
|
||||
|
||||
if (pfd.iPixelType == PFD_TYPE_RGBA) {
|
||||
int redMask = (1 << pfd.cRedBits) - 1;
|
||||
int greenMask = (1 << pfd.cGreenBits) - 1;
|
||||
int blueMask = (1 << pfd.cBlueBits) - 1;
|
||||
int i;
|
||||
|
||||
/* fill in an RGBA color palette */
|
||||
for (i = 0; i < n; ++i) {
|
||||
logical->palPalEntry[i].peRed =
|
||||
(((i >> pfd.cRedShift) & redMask) * 255) / redMask;
|
||||
logical->palPalEntry[i].peGreen =
|
||||
(((i >> pfd.cGreenShift) & greenMask) * 255) / greenMask;
|
||||
logical->palPalEntry[i].peBlue =
|
||||
(((i >> pfd.cBlueShift) & blueMask) * 255) / blueMask;
|
||||
logical->palPalEntry[i].peFlags = 0;
|
||||
}
|
||||
}
|
||||
|
||||
palette = CreatePalette(logical);
|
||||
free(logical);
|
||||
|
||||
SelectPalette(XHDC, palette, FALSE);
|
||||
RealizePalette(XHDC);
|
||||
#endif /* POKA */
|
||||
|
||||
return palette;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int GetSystemMetrics( int mode)
|
||||
{ RECTL rect;
|
||||
|
||||
switch(mode)
|
||||
{ case SM_CXSCREEN:
|
||||
WinQueryWindowRect(HWND_DESKTOP,&rect);
|
||||
return (rect.xRight-rect.xLeft);
|
||||
break;
|
||||
case SM_CYSCREEN:
|
||||
WinQueryWindowRect(HWND_DESKTOP,&rect);
|
||||
return (rect.yTop-rect.yBottom);
|
||||
break;
|
||||
default: ;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* XParseGeometry parses strings of the form
|
||||
* "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
|
||||
* width, height, xoffset, and yoffset are unsigned integers.
|
||||
* Example: "=80x24+300-49"
|
||||
* The equal sign is optional.
|
||||
* It returns a bitmask that indicates which of the four values
|
||||
* were actually found in the string. For each value found,
|
||||
* the corresponding argument is updated; for each value
|
||||
* not found, the corresponding argument is left unchanged.
|
||||
*/
|
||||
|
||||
static int
|
||||
ReadInteger(char *string, char **NextString)
|
||||
{
|
||||
register int Result = 0;
|
||||
int Sign = 1;
|
||||
|
||||
if (*string == '+')
|
||||
string++;
|
||||
else if (*string == '-')
|
||||
{
|
||||
string++;
|
||||
Sign = -1;
|
||||
}
|
||||
for (; (*string >= '0') && (*string <= '9'); string++)
|
||||
{
|
||||
Result = (Result * 10) + (*string - '0');
|
||||
}
|
||||
*NextString = string;
|
||||
if (Sign >= 0)
|
||||
return (Result);
|
||||
else
|
||||
return (-Result);
|
||||
}
|
||||
|
||||
int XParseGeometry(char *string, int *x, int *y, unsigned int *width, unsigned int *height)
|
||||
{
|
||||
int mask = NoValue;
|
||||
register char *strind;
|
||||
unsigned int tempWidth, tempHeight;
|
||||
int tempX, tempY;
|
||||
char *nextCharacter;
|
||||
|
||||
if ( (string == NULL) || (*string == '\0')) return(mask);
|
||||
if (*string == '=')
|
||||
string++; /* ignore possible '=' at beg of geometry spec */
|
||||
|
||||
strind = (char *)string;
|
||||
if (*strind != '+' && *strind != '-' && *strind != 'x') {
|
||||
tempWidth = ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return (0);
|
||||
strind = nextCharacter;
|
||||
mask |= WidthValue;
|
||||
}
|
||||
|
||||
if (*strind == 'x' || *strind == 'X') {
|
||||
strind++;
|
||||
tempHeight = ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return (0);
|
||||
strind = nextCharacter;
|
||||
mask |= HeightValue;
|
||||
}
|
||||
|
||||
if ((*strind == '+') || (*strind == '-')) {
|
||||
if (*strind == '-') {
|
||||
strind++;
|
||||
tempX = -ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return (0);
|
||||
strind = nextCharacter;
|
||||
mask |= XNegative;
|
||||
|
||||
}
|
||||
else
|
||||
{ strind++;
|
||||
tempX = ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return(0);
|
||||
strind = nextCharacter;
|
||||
}
|
||||
mask |= XValue;
|
||||
if ((*strind == '+') || (*strind == '-')) {
|
||||
if (*strind == '-') {
|
||||
strind++;
|
||||
tempY = -ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return(0);
|
||||
strind = nextCharacter;
|
||||
mask |= YNegative;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
strind++;
|
||||
tempY = ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return(0);
|
||||
strind = nextCharacter;
|
||||
}
|
||||
mask |= YValue;
|
||||
}
|
||||
}
|
||||
|
||||
/* If strind isn't at the end of the string the it's an invalid
|
||||
geometry specification. */
|
||||
|
||||
if (*strind != '\0') return (0);
|
||||
|
||||
if (mask & XValue)
|
||||
*x = tempX;
|
||||
if (mask & YValue)
|
||||
*y = tempY;
|
||||
if (mask & WidthValue)
|
||||
*width = tempWidth;
|
||||
if (mask & HeightValue)
|
||||
*height = tempHeight;
|
||||
return (mask);
|
||||
}
|
||||
|
||||
int gettimeofday(struct timeval* tp, void* tzp)
|
||||
{
|
||||
DATETIME DateTime;
|
||||
APIRET ulrc; /* Return Code. */
|
||||
|
||||
ulrc = DosGetDateTime(&DateTime);
|
||||
tp->tv_sec = 60 * (60*DateTime.hours + DateTime.minutes) + DateTime.seconds;
|
||||
tp->tv_usec = DateTime.hundredths * 10000;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
XPending(Display* display)
|
||||
{
|
||||
/* similar functionality...I don't think that it is exact, but this
|
||||
will have to do. */
|
||||
QMSG msg;
|
||||
extern HAB hab; /* PM anchor block handle */
|
||||
|
||||
//?? WinPeekMsg(hab
|
||||
return WinPeekMsg(hab, &msg, NULLHANDLE, 0, 0, PM_NOREMOVE);
|
||||
}
|
||||
|
||||
void
|
||||
__glutAdjustCoords(Window parent, int* x, int* y, int* width, int* height)
|
||||
{
|
||||
RECTL rect;
|
||||
|
||||
/* adjust the window rectangle because Win32 thinks that the x, y,
|
||||
width & height are the WHOLE window (including decorations),
|
||||
whereas GLUT treats the x, y, width & height as only the CLIENT
|
||||
area of the window. */
|
||||
rect.xLeft = *x; rect.yTop = *y;
|
||||
rect.xRight = *x + *width; rect.yBottom = *y + *height;
|
||||
|
||||
/* must adjust the coordinates according to the correct style
|
||||
because depending on the style, there may or may not be
|
||||
borders. */
|
||||
//?? AdjustWindowRect(&rect, WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
|
||||
//?? (parent ? WS_CHILD : WS_OVERLAPPEDWINDOW),
|
||||
//?? FALSE);
|
||||
/* FALSE in the third parameter = window has no menu bar */
|
||||
|
||||
/* readjust if the x and y are offscreen */
|
||||
if(rect.xLeft < 0) {
|
||||
*x = 0;
|
||||
} else {
|
||||
*x = rect.xLeft;
|
||||
}
|
||||
|
||||
if(rect.yTop < 0) {
|
||||
*y = 0;
|
||||
} else {
|
||||
*y = rect.yTop;
|
||||
}
|
||||
|
||||
*width = rect.xRight - rect.xLeft; /* adjusted width */
|
||||
*height = -(rect.yBottom - rect.yTop); /* adjusted height */
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
__glutGetTransparentPixel(Display * dpy, XVisualInfo * vinfo)
|
||||
{
|
||||
/* the transparent pixel on Win32 is always index number 0. So if
|
||||
we put this routine in this file, we can avoid compiling the
|
||||
whole of layerutil.c which is where this routine normally comes
|
||||
from. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Translate point coordinates src_x and src_y from src to dst */
|
||||
|
||||
Bool
|
||||
XTranslateCoordinates(Display *display, Window src, Window dst,
|
||||
int src_x, int src_y,
|
||||
int* dest_x_return, int* dest_y_return,
|
||||
Window* child_return)
|
||||
{
|
||||
SWP swp_src,swp_dst;
|
||||
|
||||
WinQueryWindowPos(src,&swp_src);
|
||||
WinQueryWindowPos(dst,&swp_dst);
|
||||
|
||||
*dest_x_return = src_x + swp_src.x - swp_dst.x;
|
||||
*dest_y_return = src_y + swp_src.y - swp_dst.y;
|
||||
|
||||
/* just to make compilers happy...we don't use the return value. */
|
||||
return True;
|
||||
}
|
||||
|
||||
Status
|
||||
XGetGeometry(Display* display, Window window, Window* root_return,
|
||||
int* x_return, int* y_return,
|
||||
unsigned int* width_return, unsigned int* height_return,
|
||||
unsigned int *border_width_return, unsigned int* depth_return)
|
||||
{
|
||||
/* KLUDGE: doesn't return the border_width or depth or root, x & y
|
||||
are in screen coordinates. */
|
||||
SWP swp_src;
|
||||
WinQueryWindowPos(window,&swp_src);
|
||||
|
||||
*x_return = swp_src.x;
|
||||
*y_return = swp_src.y;
|
||||
*width_return = swp_src.cx;
|
||||
*height_return = swp_src.cy;
|
||||
|
||||
/* just to make compilers happy...we don't use the return value. */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Get Display Width in millimeters */
|
||||
int
|
||||
DisplayWidthMM(Display* display, int screen)
|
||||
{
|
||||
int width;
|
||||
LONG *pVC_Caps;
|
||||
pVC_Caps = GetVideoConfig(NULLHANDLE);
|
||||
width = (int)( 0.001 * pVC_Caps[CAPS_WIDTH] / pVC_Caps[CAPS_HORIZONTAL_RESOLUTION]);/* mm */
|
||||
return width;
|
||||
}
|
||||
|
||||
/* Get Display Height in millimeters */
|
||||
int
|
||||
DisplayHeightMM(Display* display, int screen)
|
||||
{
|
||||
int height;
|
||||
LONG *pVC_Caps;
|
||||
pVC_Caps = GetVideoConfig(NULLHANDLE);
|
||||
height = (int)( 0.001 * pVC_Caps[CAPS_HEIGHT] / pVC_Caps[CAPS_VERTICAL_RESOLUTION]); /* mm */
|
||||
return height;
|
||||
}
|
||||
|
||||
void ScreenToClient( HWND hwnd, POINTL *point)
|
||||
{
|
||||
SWP swp_src;
|
||||
WinQueryWindowPos(hwnd,&swp_src);
|
||||
point->x -= swp_src.x;
|
||||
point->y -= swp_src.y;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
/***********************************************************
|
||||
* Copyright (C) 1997, Be Inc. All rights reserved.
|
||||
*
|
||||
* FILE: glutOverlay.cpp
|
||||
*
|
||||
* DESCRIPTION: we don't support overlays, so this code is
|
||||
* really simple
|
||||
***********************************************************/
|
||||
|
||||
/***********************************************************
|
||||
* Headers
|
||||
***********************************************************/
|
||||
#include <GL/glut.h>
|
||||
#include "glutint.h"
|
||||
#include "glutbitmap.h"
|
||||
#include "glutstroke.h"
|
||||
|
||||
GLUTAPI void GLUTAPIENTRY
|
||||
glutEstablishOverlay(void)
|
||||
{
|
||||
__glutFatalError("OS2PM lacks overlay support.");
|
||||
}
|
||||
|
||||
GLUTAPI void GLUTAPIENTRY
|
||||
glutUseLayer(GLenum layer) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
GLUTAPI void GLUTAPIENTRY
|
||||
glutRemoveOverlay(void) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
GLUTAPI void GLUTAPIENTRY
|
||||
glutPostOverlayRedisplay(void) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
GLUTAPI void GLUTAPIENTRY
|
||||
glutShowOverlay(void) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
GLUTAPI void GLUTAPIENTRY glutHideOverlay(void)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
int GLUTAPIENTRY
|
||||
glutLayerGet(GLenum param)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* Unsupported callbacks
|
||||
***********************************************************/
|
||||
GLUTAPI void GLUTAPIENTRY
|
||||
glutOverlayDisplayFunc(GLUTdisplayCB displayFunc)
|
||||
{
|
||||
}
|
||||
|
||||
GLUTAPI void GLUTAPIENTRY
|
||||
glutSpaceballMotionFunc(GLUTspaceMotionCB spaceMotionFunc)
|
||||
{
|
||||
}
|
||||
|
||||
GLUTAPI void GLUTAPIENTRY
|
||||
glutSpaceballRotateFunc(GLUTspaceRotateCB spaceRotateFunc)
|
||||
{
|
||||
}
|
||||
|
||||
GLUTAPI void GLUTAPIENTRY
|
||||
glutSpaceballButtonFunc(GLUTspaceButtonCB spaceButtonFunc)
|
||||
{
|
||||
}
|
||||
|
||||
GLUTAPI void GLUTAPIENTRY
|
||||
glutButtonBoxFunc(GLUTbuttonBoxCB buttonBoxFunc)
|
||||
{
|
||||
}
|
||||
|
||||
GLUTAPI void GLUTAPIENTRY
|
||||
glutDialsFunc(GLUTdialsCB dialsFunc)
|
||||
{
|
||||
}
|
||||
|
||||
GLUTAPI void GLUTAPIENTRY
|
||||
glutTabletMotionFunc(GLUTtabletMotionCB tabletMotionFunc)
|
||||
{
|
||||
}
|
||||
|
||||
GLUTAPI void GLUTAPIENTRY
|
||||
glutTabletButtonFunc(GLUTtabletButtonCB tabletButtonFunc)
|
||||
{
|
||||
}
|
||||
GLUTAPI void GLUTAPIENTRY
|
||||
glutPostWindowOverlayRedisplay(int win)
|
||||
{ //
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutInitDisplayString(const char *string)
|
||||
{ //
|
||||
}
|
||||
void GLUTAPIENTRY
|
||||
glutJoystickFunc(GLUTjoystickCB joystickFunc, int pollInterval)
|
||||
{ //
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutForceJoystickFunc(void)
|
||||
{ //
|
||||
}
|
||||
|
||||
|
||||
int GLUTAPIENTRY
|
||||
glutBitmapWidth(GLUTbitmapFont font, int c)
|
||||
{ return 0;
|
||||
}
|
||||
int GLUTAPIENTRY
|
||||
glutBitmapLength(GLUTbitmapFont font, const unsigned char *string)
|
||||
{ //
|
||||
return 0;
|
||||
}
|
||||
int GLUTAPIENTRY
|
||||
glutStrokeWidth(GLUTstrokeFont font, int c)
|
||||
{ return 0;
|
||||
}
|
||||
int GLUTAPIENTRY
|
||||
glutStrokeLength(GLUTstrokeFont font, const unsigned char *string)
|
||||
{ return 0;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,57 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1994. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#include "glutint.h"
|
||||
#include "glutbitmap.h"
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutBitmapCharacter(GLUTbitmapFont font, int c)
|
||||
{
|
||||
const BitmapCharRec *ch;
|
||||
BitmapFontPtr fontinfo;
|
||||
GLint swapbytes, lsbfirst, rowlength;
|
||||
GLint skiprows, skippixels, alignment;
|
||||
|
||||
#if defined(_WIN32)
|
||||
fontinfo = (BitmapFontPtr) __glutFont(font);
|
||||
#else
|
||||
fontinfo = (BitmapFontPtr) font;
|
||||
#endif
|
||||
|
||||
if (c < fontinfo->first ||
|
||||
c >= fontinfo->first + fontinfo->num_chars)
|
||||
return;
|
||||
ch = fontinfo->ch[c - fontinfo->first];
|
||||
if (ch) {
|
||||
/* Save current modes. */
|
||||
glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes);
|
||||
glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst);
|
||||
glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength);
|
||||
glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows);
|
||||
glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels);
|
||||
glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
|
||||
/* Little endian machines (DEC Alpha for example) could
|
||||
benefit from setting GL_UNPACK_LSB_FIRST to GL_TRUE
|
||||
instead of GL_FALSE, but this would require changing the
|
||||
generated bitmaps too. */
|
||||
glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
|
||||
glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
|
||||
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glBitmap(ch->width, ch->height, ch->xorig, ch->yorig,
|
||||
ch->advance, 0, ch->bitmap);
|
||||
/* Restore saved modes. */
|
||||
glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
|
||||
glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
|
||||
glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
|
||||
glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,259 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1994, 1996, 1997. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "glutint.h"
|
||||
|
||||
#if defined(__OS2PM__)
|
||||
#define IsWindowVisible WinIsWindowVisible
|
||||
#endif
|
||||
|
||||
#define CLAMP(i) ((i) > 1.0 ? 1.0 : ((i) < 0.0 ? 0.0 : (i)))
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY
|
||||
glutSetColor(int ndx, GLfloat red, GLfloat green, GLfloat blue)
|
||||
{
|
||||
GLUTcolormap *cmap, *newcmap;
|
||||
XVisualInfo *vis;
|
||||
XColor color;
|
||||
int i;
|
||||
|
||||
if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
|
||||
cmap = __glutCurrentWindow->colormap;
|
||||
vis = __glutCurrentWindow->vis;
|
||||
} else {
|
||||
cmap = __glutCurrentWindow->overlay->colormap;
|
||||
vis = __glutCurrentWindow->overlay->vis;
|
||||
if (ndx == __glutCurrentWindow->overlay->transparentPixel) {
|
||||
__glutWarning(
|
||||
"glutSetColor: cannot set color of overlay transparent index %d\n",
|
||||
ndx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cmap) {
|
||||
__glutWarning("glutSetColor: current window is RGBA");
|
||||
return;
|
||||
}
|
||||
#if defined(_WIN32) || defined(__OS2PM__)
|
||||
if (ndx >= 256 || /* always assume 256 colors on Win32 */
|
||||
#else
|
||||
if (ndx >= vis->visual->map_entries ||
|
||||
#endif
|
||||
ndx < 0) {
|
||||
__glutWarning("glutSetColor: index %d out of range", ndx);
|
||||
return;
|
||||
}
|
||||
if (cmap->refcnt > 1) {
|
||||
newcmap = __glutAssociateNewColormap(vis);
|
||||
cmap->refcnt--;
|
||||
/* Wouldn't it be nice if XCopyColormapAndFree could be
|
||||
told not to free the old colormap's entries! */
|
||||
for (i = cmap->size - 1; i >= 0; i--) {
|
||||
if (i == ndx) {
|
||||
/* We are going to set this cell shortly! */
|
||||
continue;
|
||||
}
|
||||
if (cmap->cells[i].component[GLUT_RED] >= 0.0) {
|
||||
color.pixel = i;
|
||||
newcmap->cells[i].component[GLUT_RED] =
|
||||
cmap->cells[i].component[GLUT_RED];
|
||||
color.red = (GLfloat) 0xffff *
|
||||
cmap->cells[i].component[GLUT_RED];
|
||||
newcmap->cells[i].component[GLUT_GREEN] =
|
||||
cmap->cells[i].component[GLUT_GREEN];
|
||||
color.green = (GLfloat) 0xffff *
|
||||
cmap->cells[i].component[GLUT_GREEN];
|
||||
newcmap->cells[i].component[GLUT_BLUE] =
|
||||
cmap->cells[i].component[GLUT_BLUE];
|
||||
color.blue = (GLfloat) 0xffff *
|
||||
cmap->cells[i].component[GLUT_BLUE];
|
||||
color.flags = DoRed | DoGreen | DoBlue;
|
||||
#if defined(_WIN32) || defined(__OS2PM__)
|
||||
if (IsWindowVisible(__glutCurrentWindow->win)) {
|
||||
XHDC = __glutCurrentWindow->hdc;
|
||||
} else {
|
||||
XHDC = 0;
|
||||
}
|
||||
#endif
|
||||
XStoreColor(__glutDisplay, newcmap->cmap, &color);
|
||||
} else {
|
||||
/* Leave unallocated entries unallocated. */
|
||||
}
|
||||
}
|
||||
cmap = newcmap;
|
||||
if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
|
||||
__glutCurrentWindow->colormap = cmap;
|
||||
__glutCurrentWindow->cmap = cmap->cmap;
|
||||
} else {
|
||||
__glutCurrentWindow->overlay->colormap = cmap;
|
||||
__glutCurrentWindow->overlay->cmap = cmap->cmap;
|
||||
}
|
||||
XSetWindowColormap(__glutDisplay,
|
||||
__glutCurrentWindow->renderWin, cmap->cmap);
|
||||
|
||||
#if !defined(_WIN32) && !defined(__OS2PM__)
|
||||
{
|
||||
GLUTwindow *toplevel;
|
||||
|
||||
toplevel = __glutToplevelOf(__glutCurrentWindow);
|
||||
if (toplevel->cmap != cmap->cmap) {
|
||||
__glutPutOnWorkList(toplevel, GLUT_COLORMAP_WORK);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
color.pixel = ndx;
|
||||
red = CLAMP(red);
|
||||
cmap->cells[ndx].component[GLUT_RED] = red;
|
||||
color.red = (GLfloat) 0xffff *red;
|
||||
green = CLAMP(green);
|
||||
cmap->cells[ndx].component[GLUT_GREEN] = green;
|
||||
color.green = (GLfloat) 0xffff *green;
|
||||
blue = CLAMP(blue);
|
||||
cmap->cells[ndx].component[GLUT_BLUE] = blue;
|
||||
color.blue = (GLfloat) 0xffff *blue;
|
||||
color.flags = DoRed | DoGreen | DoBlue;
|
||||
#if defined(_WIN32) || defined(__OS2PM__)
|
||||
if (IsWindowVisible(__glutCurrentWindow->win)) {
|
||||
XHDC = __glutCurrentWindow->hdc;
|
||||
} else {
|
||||
XHDC = 0;
|
||||
}
|
||||
#endif
|
||||
XStoreColor(__glutDisplay, cmap->cmap, &color);
|
||||
}
|
||||
|
||||
GLfloat GLUTAPIENTRY
|
||||
glutGetColor(int ndx, int comp)
|
||||
{
|
||||
GLUTcolormap *colormap;
|
||||
XVisualInfo *vis;
|
||||
|
||||
if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
|
||||
colormap = __glutCurrentWindow->colormap;
|
||||
vis = __glutCurrentWindow->vis;
|
||||
} else {
|
||||
colormap = __glutCurrentWindow->overlay->colormap;
|
||||
vis = __glutCurrentWindow->overlay->vis;
|
||||
if (ndx == __glutCurrentWindow->overlay->transparentPixel) {
|
||||
__glutWarning("glutGetColor: requesting overlay transparent index %d\n",
|
||||
ndx);
|
||||
return -1.0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!colormap) {
|
||||
__glutWarning("glutGetColor: current window is RGBA");
|
||||
return -1.0;
|
||||
}
|
||||
#if defined(_WIN32) || defined(__OS2PM__)
|
||||
#define OUT_OF_RANGE_NDX(ndx) (ndx >= 256 || ndx < 0)
|
||||
#else
|
||||
#define OUT_OF_RANGE_NDX(ndx) (ndx >= vis->visual->map_entries || ndx < 0)
|
||||
#endif
|
||||
if (OUT_OF_RANGE_NDX(ndx)) {
|
||||
__glutWarning("glutGetColor: index %d out of range", ndx);
|
||||
return -1.0;
|
||||
}
|
||||
return colormap->cells[ndx].component[comp];
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutCopyColormap(int winnum)
|
||||
{
|
||||
GLUTwindow *window = __glutWindowList[winnum - 1];
|
||||
GLUTcolormap *oldcmap, *newcmap;
|
||||
XVisualInfo *dstvis;
|
||||
|
||||
if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
|
||||
oldcmap = __glutCurrentWindow->colormap;
|
||||
dstvis = __glutCurrentWindow->vis;
|
||||
newcmap = window->colormap;
|
||||
} else {
|
||||
oldcmap = __glutCurrentWindow->overlay->colormap;
|
||||
dstvis = __glutCurrentWindow->overlay->vis;
|
||||
if (!window->overlay) {
|
||||
__glutWarning("glutCopyColormap: window %d has no overlay", winnum);
|
||||
return;
|
||||
}
|
||||
newcmap = window->overlay->colormap;
|
||||
}
|
||||
|
||||
if (!oldcmap) {
|
||||
__glutWarning("glutCopyColormap: destination colormap must be color index");
|
||||
return;
|
||||
}
|
||||
if (!newcmap) {
|
||||
__glutWarning(
|
||||
"glutCopyColormap: source colormap of window %d must be color index",
|
||||
winnum);
|
||||
return;
|
||||
}
|
||||
if (newcmap == oldcmap) {
|
||||
/* Source and destination are the same; now copy needed. */
|
||||
return;
|
||||
}
|
||||
#if !defined(_WIN32) && !defined(__OS2PM__)
|
||||
/* Play safe: compare visual IDs, not Visual*'s. */
|
||||
if (newcmap->visual->visualid == oldcmap->visual->visualid) {
|
||||
#endif
|
||||
/* Visuals match! "Copy" by reference... */
|
||||
__glutFreeColormap(oldcmap);
|
||||
newcmap->refcnt++;
|
||||
if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
|
||||
__glutCurrentWindow->colormap = newcmap;
|
||||
__glutCurrentWindow->cmap = newcmap->cmap;
|
||||
} else {
|
||||
__glutCurrentWindow->overlay->colormap = newcmap;
|
||||
__glutCurrentWindow->overlay->cmap = newcmap->cmap;
|
||||
}
|
||||
XSetWindowColormap(__glutDisplay, __glutCurrentWindow->renderWin,
|
||||
newcmap->cmap);
|
||||
#if !defined(_WIN32) && !defined(__OS2PM__)
|
||||
__glutPutOnWorkList(__glutToplevelOf(window), GLUT_COLORMAP_WORK);
|
||||
bla bla bla
|
||||
|
||||
} else {
|
||||
GLUTcolormap *copycmap;
|
||||
XColor color;
|
||||
int i, last;
|
||||
|
||||
/* Visuals different - need a distinct X colormap! */
|
||||
copycmap = __glutAssociateNewColormap(dstvis);
|
||||
/* Wouldn't it be nice if XCopyColormapAndFree could be
|
||||
told not to free the old colormap's entries! */
|
||||
last = newcmap->size;
|
||||
if (last > copycmap->size) {
|
||||
last = copycmap->size;
|
||||
}
|
||||
for (i = last - 1; i >= 0; i--) {
|
||||
if (newcmap->cells[i].component[GLUT_RED] >= 0.0) {
|
||||
color.pixel = i;
|
||||
copycmap->cells[i].component[GLUT_RED] =
|
||||
newcmap->cells[i].component[GLUT_RED];
|
||||
color.red = (GLfloat) 0xffff *
|
||||
newcmap->cells[i].component[GLUT_RED];
|
||||
copycmap->cells[i].component[GLUT_GREEN] =
|
||||
newcmap->cells[i].component[GLUT_GREEN];
|
||||
color.green = (GLfloat) 0xffff *
|
||||
newcmap->cells[i].component[GLUT_GREEN];
|
||||
copycmap->cells[i].component[GLUT_BLUE] =
|
||||
newcmap->cells[i].component[GLUT_BLUE];
|
||||
color.blue = (GLfloat) 0xffff *
|
||||
newcmap->cells[i].component[GLUT_BLUE];
|
||||
color.flags = DoRed | DoGreen | DoBlue;
|
||||
XStoreColor(__glutDisplay, copycmap->cmap, &color);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/* ENDCENTRY */
|
||||
|
|
@ -0,0 +1,399 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1994, 1996, 1997. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#ifdef __VMS
|
||||
//EK#include <GL/vms_x_fix.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h> /* SunOS multithreaded assert() needs <stdio.h>. Lame. */
|
||||
#include <assert.h>
|
||||
#if !defined(_WIN32) && !defined(__OS2__)
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h> /* for XA_RGB_DEFAULT_MAP atom */
|
||||
#if defined(__vms)
|
||||
#include <Xmu/StdCmap.h> /* for XmuLookupStandardColormap */
|
||||
#else
|
||||
#include <X11/Xmu/StdCmap.h> /* for XmuLookupStandardColormap */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* SGI optimization introduced in IRIX 6.3 to avoid X server
|
||||
round trips for interning common X atoms. */
|
||||
#if defined(_SGI_EXTRA_PREDEFINES) && !defined(NO_FAST_ATOMS)
|
||||
#include <X11/SGIFastAtom.h>
|
||||
#else
|
||||
#define XSGIFastInternAtom(dpy,string,fast_name,how) XInternAtom(dpy,string,how)
|
||||
#endif
|
||||
|
||||
#include "glutint.h"
|
||||
#include "layerutil.h"
|
||||
|
||||
GLUTcolormap *__glutColormapList = NULL;
|
||||
|
||||
GLUTcolormap *
|
||||
__glutAssociateNewColormap(XVisualInfo * vis)
|
||||
{
|
||||
GLUTcolormap *cmap;
|
||||
int transparentPixel, i;
|
||||
unsigned long pixels[255];
|
||||
|
||||
cmap = (GLUTcolormap *) malloc(sizeof(GLUTcolormap));
|
||||
if (!cmap)
|
||||
__glutFatalError("out of memory.");
|
||||
#if defined(_WIN32) || defined(__OS2__)
|
||||
pixels[0] = 0; /* avoid compilation warnings on win32 */
|
||||
cmap->visual = 0;
|
||||
cmap->size = 256; /* always assume 256 on Win32 */
|
||||
#else
|
||||
cmap->visual = vis->visual;
|
||||
cmap->size = vis->visual->map_entries;
|
||||
#endif
|
||||
cmap->refcnt = 1;
|
||||
cmap->cells = (GLUTcolorcell *)
|
||||
malloc(sizeof(GLUTcolorcell) * cmap->size);
|
||||
if (!cmap->cells)
|
||||
__glutFatalError("out of memory.");
|
||||
/* make all color cell entries be invalid */
|
||||
for (i = cmap->size - 1; i >= 0; i--) {
|
||||
cmap->cells[i].component[GLUT_RED] = -1.0;
|
||||
cmap->cells[i].component[GLUT_GREEN] = -1.0;
|
||||
cmap->cells[i].component[GLUT_BLUE] = -1.0;
|
||||
}
|
||||
transparentPixel = __glutGetTransparentPixel(__glutDisplay, vis);
|
||||
if (transparentPixel == -1 || transparentPixel >= cmap->size) {
|
||||
|
||||
/* If there is no transparent pixel or if the transparent
|
||||
pixel is outside the range of valid colormap cells (HP
|
||||
can implement their overlays this smart way since their
|
||||
transparent pixel is 255), we can AllocAll the colormap.
|
||||
See note below. */
|
||||
|
||||
cmap->cmap = XCreateColormap(__glutDisplay,
|
||||
__glutRoot, cmap->visual, AllocAll);
|
||||
} else {
|
||||
|
||||
/* On machines where zero (or some other value in the range
|
||||
of 0 through map_entries-1), BadAlloc may be generated
|
||||
when an AllocAll overlay colormap is allocated since the
|
||||
transparent pixel precludes all the cells in the colormap
|
||||
being allocated (the transparent pixel is pre-allocated).
|
||||
So in this case, use XAllocColorCells to allocate
|
||||
map_entries-1 pixels (that is, all but the transparent
|
||||
pixel. */
|
||||
|
||||
#if defined(_WIN32) || defined(__OS2__)
|
||||
cmap->cmap = XCreateColormap(__glutDisplay,
|
||||
__glutRoot, 0, AllocNone);
|
||||
#else
|
||||
cmap->cmap = XCreateColormap(__glutDisplay,
|
||||
__glutRoot, vis->visual, AllocNone);
|
||||
XAllocColorCells(__glutDisplay, cmap->cmap, False, 0, 0,
|
||||
pixels, cmap->size - 1);
|
||||
#endif
|
||||
}
|
||||
cmap->next = __glutColormapList;
|
||||
__glutColormapList = cmap;
|
||||
return cmap;
|
||||
}
|
||||
|
||||
static GLUTcolormap *
|
||||
associateColormap(XVisualInfo * vis)
|
||||
{
|
||||
#if !defined(_WIN32) && !defined(__OS2__)
|
||||
GLUTcolormap *cmap = __glutColormapList;
|
||||
|
||||
while (cmap != NULL) {
|
||||
/* Play safe: compare visual IDs, not Visual*'s. */
|
||||
if (cmap->visual->visualid == vis->visual->visualid) {
|
||||
/* Already have created colormap for the visual. */
|
||||
cmap->refcnt++;
|
||||
return cmap;
|
||||
}
|
||||
cmap = cmap->next;
|
||||
}
|
||||
#endif
|
||||
return __glutAssociateNewColormap(vis);
|
||||
}
|
||||
|
||||
void
|
||||
__glutSetupColormap(XVisualInfo * vi, GLUTcolormap ** colormap, Colormap * cmap)
|
||||
{
|
||||
#if defined(_WIN32) || defined(__OS2__)
|
||||
if (vi->dwFlags & PFD_NEED_PALETTE || vi->iPixelType == PFD_TYPE_COLORINDEX) {
|
||||
*colormap = associateColormap(vi);
|
||||
*cmap = (*colormap)->cmap;
|
||||
} else {
|
||||
*colormap = NULL;
|
||||
*cmap = 0;
|
||||
}
|
||||
#else
|
||||
Status status;
|
||||
XStandardColormap *standardCmaps;
|
||||
int i, numCmaps;
|
||||
static Atom hpColorRecoveryAtom = -1;
|
||||
int isRGB, visualClass, rc;
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
visualClass = vi->c_class;
|
||||
#else
|
||||
visualClass = vi->class;
|
||||
#endif
|
||||
switch (visualClass) {
|
||||
case PseudoColor:
|
||||
/* Mesa might return a PseudoColor visual for RGB mode. */
|
||||
rc = glXGetConfig(__glutDisplay, vi, GLX_RGBA, &isRGB);
|
||||
if (rc == 0 && isRGB) {
|
||||
/* Must be Mesa. */
|
||||
*colormap = NULL;
|
||||
if (MaxCmapsOfScreen(DefaultScreenOfDisplay(__glutDisplay)) == 1
|
||||
&& vi->visual == DefaultVisual(__glutDisplay, __glutScreen)) {
|
||||
char *privateCmap = getenv("MESA_PRIVATE_CMAP");
|
||||
|
||||
if (privateCmap) {
|
||||
/* User doesn't want to share colormaps. */
|
||||
*cmap = XCreateColormap(__glutDisplay, __glutRoot,
|
||||
vi->visual, AllocNone);
|
||||
} else {
|
||||
/* Share the root colormap. */
|
||||
*cmap = DefaultColormap(__glutDisplay, __glutScreen);
|
||||
}
|
||||
} else {
|
||||
/* Get our own PseudoColor colormap. */
|
||||
*cmap = XCreateColormap(__glutDisplay, __glutRoot,
|
||||
vi->visual, AllocNone);
|
||||
}
|
||||
} else {
|
||||
/* CI mode, real GLX never returns a PseudoColor visual
|
||||
for RGB mode. */
|
||||
*colormap = associateColormap(vi);
|
||||
*cmap = (*colormap)->cmap;
|
||||
}
|
||||
break;
|
||||
case TrueColor:
|
||||
case DirectColor:
|
||||
*colormap = NULL; /* NULL if RGBA */
|
||||
|
||||
/* Hewlett-Packard supports a feature called "HP Color
|
||||
Recovery". Mesa has code to use HP Color Recovery. For
|
||||
Mesa to use this feature, the atom
|
||||
_HP_RGB_SMOOTH_MAP_LIST must be defined on the root
|
||||
window AND the colormap obtainable by XGetRGBColormaps
|
||||
for that atom must be set on the window. If that
|
||||
colormap is not set, the output will look stripy. */
|
||||
|
||||
if (hpColorRecoveryAtom == -1) {
|
||||
char *xvendor;
|
||||
|
||||
#define VENDOR_HP "Hewlett-Packard"
|
||||
|
||||
/* Only makes sense to make XInternAtom round-trip if we
|
||||
know that we are connected to an HP X server. */
|
||||
xvendor = ServerVendor(__glutDisplay);
|
||||
if (!strncmp(xvendor, VENDOR_HP, sizeof(VENDOR_HP) - 1)) {
|
||||
hpColorRecoveryAtom = XInternAtom(__glutDisplay, "_HP_RGB_SMOOTH_MAP_LIST", True);
|
||||
} else {
|
||||
hpColorRecoveryAtom = None;
|
||||
}
|
||||
}
|
||||
if (hpColorRecoveryAtom != None) {
|
||||
status = XGetRGBColormaps(__glutDisplay, __glutRoot,
|
||||
&standardCmaps, &numCmaps, hpColorRecoveryAtom);
|
||||
if (status == 1) {
|
||||
for (i = 0; i < numCmaps; i++) {
|
||||
if (standardCmaps[i].visualid == vi->visualid) {
|
||||
*cmap = standardCmaps[i].colormap;
|
||||
XFree(standardCmaps);
|
||||
return;
|
||||
}
|
||||
}
|
||||
XFree(standardCmaps);
|
||||
}
|
||||
}
|
||||
#ifndef SOLARIS_2_4_BUG
|
||||
/* Solaris 2.4 and 2.5 have a bug in their
|
||||
XmuLookupStandardColormap implementations. Please
|
||||
compile your Solaris 2.4 or 2.5 version of GLUT with
|
||||
-DSOLARIS_2_4_BUG to work around this bug. The symptom
|
||||
of the bug is that programs will get a BadMatch error
|
||||
from X_CreateWindow when creating a GLUT window because
|
||||
Solaris 2.4 and 2.5 create a corrupted RGB_DEFAULT_MAP
|
||||
property. Note that this workaround prevents Colormap
|
||||
sharing between applications, perhaps leading
|
||||
unnecessary colormap installations or colormap flashing.
|
||||
Sun fixed this bug in Solaris 2.6. */
|
||||
status = XmuLookupStandardColormap(__glutDisplay,
|
||||
vi->screen, vi->visualid, vi->depth, XA_RGB_DEFAULT_MAP,
|
||||
/* replace */ False, /* retain */ True);
|
||||
if (status == 1) {
|
||||
status = XGetRGBColormaps(__glutDisplay, __glutRoot,
|
||||
&standardCmaps, &numCmaps, XA_RGB_DEFAULT_MAP);
|
||||
if (status == 1) {
|
||||
for (i = 0; i < numCmaps; i++) {
|
||||
if (standardCmaps[i].visualid == vi->visualid) {
|
||||
*cmap = standardCmaps[i].colormap;
|
||||
XFree(standardCmaps);
|
||||
return;
|
||||
}
|
||||
}
|
||||
XFree(standardCmaps);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* If no standard colormap but TrueColor, just make a
|
||||
private one. */
|
||||
/* XXX Should do a better job of internal sharing for
|
||||
privately allocated TrueColor colormaps. */
|
||||
/* XXX DirectColor probably needs ramps hand initialized! */
|
||||
*cmap = XCreateColormap(__glutDisplay, __glutRoot,
|
||||
vi->visual, AllocNone);
|
||||
break;
|
||||
case StaticColor:
|
||||
case StaticGray:
|
||||
case GrayScale:
|
||||
/* Mesa supports these visuals */
|
||||
*colormap = NULL;
|
||||
*cmap = XCreateColormap(__glutDisplay, __glutRoot,
|
||||
vi->visual, AllocNone);
|
||||
break;
|
||||
default:
|
||||
__glutFatalError(
|
||||
"could not allocate colormap for visual type: %d.",
|
||||
visualClass);
|
||||
}
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(_WIN32) && !defined(__OS2__)
|
||||
static int
|
||||
findColormaps(GLUTwindow * window,
|
||||
Window * winlist, Colormap * cmaplist, int num, int max)
|
||||
{
|
||||
GLUTwindow *child;
|
||||
int i;
|
||||
|
||||
/* Do not allow more entries that maximum number of
|
||||
colormaps! */
|
||||
if (num >= max)
|
||||
return num;
|
||||
/* Is cmap for this window already on the list? */
|
||||
for (i = 0; i < num; i++) {
|
||||
if (cmaplist[i] == window->cmap)
|
||||
goto normalColormapAlreadyListed;
|
||||
}
|
||||
/* Not found on the list; add colormap and window. */
|
||||
winlist[num] = window->win;
|
||||
cmaplist[num] = window->cmap;
|
||||
num++;
|
||||
|
||||
normalColormapAlreadyListed:
|
||||
|
||||
/* Repeat above but for the overlay colormap if there one. */
|
||||
if (window->overlay) {
|
||||
if (num >= max)
|
||||
return num;
|
||||
for (i = 0; i < num; i++) {
|
||||
if (cmaplist[i] == window->overlay->cmap)
|
||||
goto overlayColormapAlreadyListed;
|
||||
}
|
||||
winlist[num] = window->overlay->win;
|
||||
cmaplist[num] = window->overlay->cmap;
|
||||
num++;
|
||||
}
|
||||
overlayColormapAlreadyListed:
|
||||
|
||||
/* Recursively search children. */
|
||||
child = window->children;
|
||||
while (child) {
|
||||
num = findColormaps(child, winlist, cmaplist, num, max);
|
||||
child = child->siblings;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
void
|
||||
__glutEstablishColormapsProperty(GLUTwindow * window)
|
||||
{
|
||||
/* this routine is strictly X. Win32 doesn't need to do
|
||||
anything of this sort (but has to do other wacky stuff
|
||||
later). */
|
||||
static Atom wmColormapWindows = None;
|
||||
Window *winlist;
|
||||
Colormap *cmaplist;
|
||||
Status status;
|
||||
int maxcmaps, num;
|
||||
|
||||
assert(!window->parent);
|
||||
maxcmaps = MaxCmapsOfScreen(ScreenOfDisplay(__glutDisplay,
|
||||
__glutScreen));
|
||||
/* For portability reasons we don't use alloca for winlist
|
||||
and cmaplist, but we could. */
|
||||
winlist = (Window *) malloc(maxcmaps * sizeof(Window));
|
||||
cmaplist = (Colormap *) malloc(maxcmaps * sizeof(Colormap));
|
||||
num = findColormaps(window, winlist, cmaplist, 0, maxcmaps);
|
||||
if (num < 2) {
|
||||
/* Property no longer needed; remove it. */
|
||||
wmColormapWindows = XSGIFastInternAtom(__glutDisplay,
|
||||
"WM_COLORMAP_WINDOWS", SGI_XA_WM_COLORMAP_WINDOWS, False);
|
||||
if (wmColormapWindows == None) {
|
||||
__glutWarning("Could not intern X atom for WM_COLORMAP_WINDOWS.");
|
||||
return;
|
||||
}
|
||||
XDeleteProperty(__glutDisplay, window->win, wmColormapWindows);
|
||||
} else {
|
||||
status = XSetWMColormapWindows(__glutDisplay, window->win,
|
||||
winlist, num);
|
||||
/* XSetWMColormapWindows should always work unless the
|
||||
WM_COLORMAP_WINDOWS property cannot be intern'ed. We
|
||||
check to be safe. */
|
||||
if (status == False)
|
||||
__glutFatalError("XSetWMColormapWindows returned False.");
|
||||
}
|
||||
/* For portability reasons we don't use alloca for winlist
|
||||
and cmaplist, but we could. */
|
||||
free(winlist);
|
||||
free(cmaplist);
|
||||
}
|
||||
|
||||
GLUTwindow *
|
||||
__glutToplevelOf(GLUTwindow * window)
|
||||
{
|
||||
while (window->parent) {
|
||||
window = window->parent;
|
||||
}
|
||||
return window;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
__glutFreeColormap(GLUTcolormap * cmap)
|
||||
{
|
||||
GLUTcolormap *cur, **prev;
|
||||
|
||||
cmap->refcnt--;
|
||||
if (cmap->refcnt == 0) {
|
||||
/* remove from colormap list */
|
||||
cur = __glutColormapList;
|
||||
prev = &__glutColormapList;
|
||||
while (cur) {
|
||||
if (cur == cmap) {
|
||||
*prev = cmap->next;
|
||||
break;
|
||||
}
|
||||
prev = &(cur->next);
|
||||
cur = cur->next;
|
||||
}
|
||||
/* actually free colormap */
|
||||
XFreeColormap(__glutDisplay, cmap->cmap);
|
||||
free(cmap->cells);
|
||||
free(cmap);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,210 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1995, 1998. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#include "glutint.h"
|
||||
|
||||
#if !defined(_WIN32) && !defined(__OS2PM__)
|
||||
#include <X11/Xatom.h> /* For XA_CURSOR */
|
||||
#include <X11/cursorfont.h>
|
||||
#endif
|
||||
|
||||
typedef struct _CursorTable {
|
||||
#if defined(_WIN32)
|
||||
char* glyph;
|
||||
#else
|
||||
int glyph;
|
||||
#endif
|
||||
Cursor cursor;
|
||||
} CursorTable;
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
static CursorTable cursorTable[] = {
|
||||
{XC_arrow, None}, /* GLUT_CURSOR_RIGHT_ARROW */
|
||||
{XC_top_left_arrow, None}, /* GLUT_CURSOR_LEFT_ARROW */
|
||||
{XC_hand1, None}, /* GLUT_CURSOR_INFO */
|
||||
{XC_pirate, None}, /* GLUT_CURSOR_DESTROY */
|
||||
{XC_question_arrow, None}, /* GLUT_CURSOR_HELP */
|
||||
{XC_exchange, None}, /* GLUT_CURSOR_CYCLE */
|
||||
{XC_spraycan, None}, /* GLUT_CURSOR_SPRAY */
|
||||
{XC_watch, None}, /* GLUT_CURSOR_WAIT */
|
||||
{XC_xterm, None}, /* GLUT_CURSOR_TEXT */
|
||||
{XC_crosshair, None}, /* GLUT_CURSOR_CROSSHAIR */
|
||||
{XC_sb_v_double_arrow, None}, /* GLUT_CURSOR_UP_DOWN */
|
||||
{XC_sb_h_double_arrow, None}, /* GLUT_CURSOR_LEFT_RIGHT */
|
||||
{XC_top_side, None}, /* GLUT_CURSOR_TOP_SIDE */
|
||||
{XC_bottom_side, None}, /* GLUT_CURSOR_BOTTOM_SIDE */
|
||||
{XC_left_side, None}, /* GLUT_CURSOR_LEFT_SIDE */
|
||||
{XC_right_side, None}, /* GLUT_CURSOR_RIGHT_SIDE */
|
||||
{XC_top_left_corner, None}, /* GLUT_CURSOR_TOP_LEFT_CORNER */
|
||||
{XC_top_right_corner, None}, /* GLUT_CURSOR_TOP_RIGHT_CORNER */
|
||||
{XC_bottom_right_corner, None}, /* GLUT_CURSOR_BOTTOM_RIGHT_CORNER */
|
||||
{XC_bottom_left_corner, None}, /* GLUT_CURSOR_BOTTOM_LEFT_CORNER */
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#if !defined(_WIN32) && !defined(__OS2PM__)
|
||||
static Cursor blankCursor = None;
|
||||
static Cursor fullCrosshairCusor = None;
|
||||
|
||||
/* SGI X server's support a special property called the
|
||||
_SGI_CROSSHAIR_CURSOR that when installed as a window's
|
||||
cursor, becomes a full screen crosshair cursor. SGI
|
||||
has special cursor generation hardware for this case. */
|
||||
static Cursor
|
||||
getFullCrosshairCursor(void)
|
||||
{
|
||||
Cursor cursor;
|
||||
Atom crosshairAtom, actualType;
|
||||
int rc, actualFormat;
|
||||
unsigned long n, left;
|
||||
unsigned long *value;
|
||||
|
||||
if (fullCrosshairCusor == None) {
|
||||
crosshairAtom = XInternAtom(__glutDisplay,
|
||||
"_SGI_CROSSHAIR_CURSOR", True);
|
||||
if (crosshairAtom != None) {
|
||||
value = 0; /* Make compiler happy. */
|
||||
rc = XGetWindowProperty(__glutDisplay, __glutRoot,
|
||||
crosshairAtom, 0, 1, False, XA_CURSOR, &actualType,
|
||||
&actualFormat, &n, &left, (unsigned char **) &value);
|
||||
if (rc == Success && actualFormat == 32 && n >= 1) {
|
||||
cursor = value[0];
|
||||
XFree(value);
|
||||
return cursor;
|
||||
}
|
||||
}
|
||||
}
|
||||
return XCreateFontCursor(__glutDisplay, XC_crosshair);
|
||||
}
|
||||
|
||||
/* X11 forces you to create a blank cursor if you want
|
||||
to disable the cursor. */
|
||||
static Cursor
|
||||
makeBlankCursor(void)
|
||||
{
|
||||
static char data[1] =
|
||||
{0};
|
||||
Cursor cursor;
|
||||
Pixmap blank;
|
||||
XColor dummy;
|
||||
|
||||
blank = XCreateBitmapFromData(__glutDisplay, __glutRoot,
|
||||
data, 1, 1);
|
||||
if (blank == None)
|
||||
__glutFatalError("out of memory.");
|
||||
cursor = XCreatePixmapCursor(__glutDisplay, blank, blank,
|
||||
&dummy, &dummy, 0, 0);
|
||||
XFreePixmap(__glutDisplay, blank);
|
||||
|
||||
return cursor;
|
||||
}
|
||||
#endif /* !_WIN32 && !__OS2PM__*/
|
||||
|
||||
/* Win32 and X11 use this same function to accomplish
|
||||
fairly different tasks. X11 lets you just define the
|
||||
cursor for a window and the window system takes care
|
||||
of making sure that the window's cursor is installed
|
||||
when the mouse is in the window. Win32 requires the
|
||||
application to handle a WM_SETCURSOR message to install
|
||||
the right cursor when windows are entered. Think of
|
||||
the Win32 __glutSetCursor (called from __glutWindowProc)
|
||||
as "install cursor". Think of the X11 __glutSetCursor
|
||||
(called from glutSetCursor) as "define cursor". */
|
||||
void
|
||||
__glutSetCursor(GLUTwindow *window)
|
||||
{
|
||||
int cursor = window->cursor;
|
||||
Cursor xcursor = 0;
|
||||
|
||||
if (cursor >= 0 &&
|
||||
cursor < sizeof(cursorTable) / sizeof(cursorTable[0])) {
|
||||
if (cursorTable[cursor].cursor == None) {
|
||||
cursorTable[cursor].cursor = XCreateFontCursor(__glutDisplay,
|
||||
cursorTable[cursor].glyph);
|
||||
}
|
||||
xcursor = cursorTable[cursor].cursor;
|
||||
} else {
|
||||
/* Special cases. */
|
||||
switch (cursor) {
|
||||
case GLUT_CURSOR_INHERIT:
|
||||
#if defined(_WIN32)
|
||||
while (window->parent) {
|
||||
window = window->parent;
|
||||
if (window->cursor != GLUT_CURSOR_INHERIT) {
|
||||
__glutSetCursor(window);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* XXX Default to an arrow cursor. Is this
|
||||
right or should we be letting the default
|
||||
window proc be installing some system cursor? */
|
||||
xcursor = cursorTable[0].cursor;
|
||||
if (xcursor == NULL) {
|
||||
xcursor =
|
||||
cursorTable[0].cursor =
|
||||
LoadCursor(NULL, cursorTable[0].glyph);
|
||||
}
|
||||
|
||||
#elif defined(__OS2PM__)
|
||||
//todo
|
||||
xcursor = None;
|
||||
|
||||
#else
|
||||
xcursor = None;
|
||||
#endif
|
||||
break;
|
||||
case GLUT_CURSOR_NONE:
|
||||
#if defined(_WIN32) || defined(__OS2PM__)
|
||||
xcursor = NULL;
|
||||
#else
|
||||
if (blankCursor == None) {
|
||||
blankCursor = makeBlankCursor();
|
||||
}
|
||||
xcursor = blankCursor;
|
||||
#endif
|
||||
break;
|
||||
case GLUT_CURSOR_FULL_CROSSHAIR:
|
||||
#if defined(_WIN32)
|
||||
xcursor = (HICON) IDC_CROSS;
|
||||
#elif defined(__OS2PM__)
|
||||
//todo
|
||||
#else
|
||||
if (fullCrosshairCusor == None) {
|
||||
fullCrosshairCusor = getFullCrosshairCursor();
|
||||
}
|
||||
xcursor = fullCrosshairCusor;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
XDefineCursor(__glutDisplay,
|
||||
window->win, xcursor);
|
||||
XFlush(__glutDisplay);
|
||||
}
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY
|
||||
glutSetCursor(int cursor)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
POINT point;
|
||||
|
||||
__glutCurrentWindow->cursor = cursor;
|
||||
/* Are we in the window right now? If so,
|
||||
install the cursor. */
|
||||
GetCursorPos(&point);
|
||||
if (__glutCurrentWindow->win == WindowFromPoint(point)) {
|
||||
__glutSetCursor(__glutCurrentWindow);
|
||||
}
|
||||
#elif defined(__OS2PM__)
|
||||
//todo
|
||||
#else
|
||||
__glutCurrentWindow->cursor = cursor;
|
||||
__glutSetCursor(__glutCurrentWindow);
|
||||
#endif
|
||||
}
|
||||
/* ENDCENTRY */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,204 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1994, 1997. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "glutint.h"
|
||||
|
||||
/* CENTRY */
|
||||
int GLUTAPIENTRY
|
||||
glutExtensionSupported(const char *extension)
|
||||
{
|
||||
static const GLubyte *extensions = NULL;
|
||||
const GLubyte *start;
|
||||
GLubyte *where, *terminator;
|
||||
|
||||
/* Extension names should not have spaces. */
|
||||
where = (GLubyte *) strchr(extension, ' ');
|
||||
if (where || *extension == '\0')
|
||||
return 0;
|
||||
|
||||
if (!extensions) {
|
||||
extensions = glGetString(GL_EXTENSIONS);
|
||||
}
|
||||
/* It takes a bit of care to be fool-proof about parsing the
|
||||
OpenGL extensions string. Don't be fooled by sub-strings,
|
||||
etc. */
|
||||
start = extensions;
|
||||
for (;;) {
|
||||
/* If your application crashes in the strstr routine below,
|
||||
you are probably calling glutExtensionSupported without
|
||||
having a current window. Calling glGetString without
|
||||
a current OpenGL context has unpredictable results.
|
||||
Please fix your program. */
|
||||
where = (GLubyte *) strstr((const char *) start, extension);
|
||||
if (!where)
|
||||
break;
|
||||
terminator = where + strlen(extension);
|
||||
if (where == start || *(where - 1) == ' ') {
|
||||
if (*terminator == ' ' || *terminator == '\0') {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
start = terminator;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
struct name_address_pair {
|
||||
const char *name;
|
||||
const void *address;
|
||||
};
|
||||
|
||||
static struct name_address_pair glut_functions[] = {
|
||||
{ "glutInit", (const void *) glutInit },
|
||||
{ "glutInitDisplayMode", (const void *) glutInitDisplayMode },
|
||||
{ "glutInitDisplayString", (const void *) glutInitDisplayString },
|
||||
{ "glutInitWindowPosition", (const void *) glutInitWindowPosition },
|
||||
{ "glutInitWindowSize", (const void *) glutInitWindowSize },
|
||||
{ "glutMainLoop", (const void *) glutMainLoop },
|
||||
{ "glutCreateWindow", (const void *) glutCreateWindow },
|
||||
{ "glutCreateSubWindow", (const void *) glutCreateSubWindow },
|
||||
{ "glutDestroyWindow", (const void *) glutDestroyWindow },
|
||||
{ "glutPostRedisplay", (const void *) glutPostRedisplay },
|
||||
{ "glutPostWindowRedisplay", (const void *) glutPostWindowRedisplay },
|
||||
{ "glutSwapBuffers", (const void *) glutSwapBuffers },
|
||||
{ "glutGetWindow", (const void *) glutGetWindow },
|
||||
{ "glutSetWindow", (const void *) glutSetWindow },
|
||||
{ "glutSetWindowTitle", (const void *) glutSetWindowTitle },
|
||||
{ "glutSetIconTitle", (const void *) glutSetIconTitle },
|
||||
{ "glutPositionWindow", (const void *) glutPositionWindow },
|
||||
{ "glutReshapeWindow", (const void *) glutReshapeWindow },
|
||||
{ "glutPopWindow", (const void *) glutPopWindow },
|
||||
{ "glutPushWindow", (const void *) glutPushWindow },
|
||||
{ "glutIconifyWindow", (const void *) glutIconifyWindow },
|
||||
{ "glutShowWindow", (const void *) glutShowWindow },
|
||||
{ "glutHideWindow", (const void *) glutHideWindow },
|
||||
{ "glutFullScreen", (const void *) glutFullScreen },
|
||||
{ "glutSetCursor", (const void *) glutSetCursor },
|
||||
{ "glutWarpPointer", (const void *) glutWarpPointer },
|
||||
{ "glutEstablishOverlay", (const void *) glutEstablishOverlay },
|
||||
{ "glutRemoveOverlay", (const void *) glutRemoveOverlay },
|
||||
{ "glutUseLayer", (const void *) glutUseLayer },
|
||||
{ "glutPostOverlayRedisplay", (const void *) glutPostOverlayRedisplay },
|
||||
{ "glutPostWindowOverlayRedisplay", (const void *) glutPostWindowOverlayRedisplay },
|
||||
{ "glutShowOverlay", (const void *) glutShowOverlay },
|
||||
{ "glutHideOverlay", (const void *) glutHideOverlay },
|
||||
{ "glutCreateMenu", (const void *) glutCreateMenu },
|
||||
{ "glutDestroyMenu", (const void *) glutDestroyMenu },
|
||||
{ "glutGetMenu", (const void *) glutGetMenu },
|
||||
{ "glutSetMenu", (const void *) glutSetMenu },
|
||||
{ "glutAddMenuEntry", (const void *) glutAddMenuEntry },
|
||||
{ "glutAddSubMenu", (const void *) glutAddSubMenu },
|
||||
{ "glutChangeToMenuEntry", (const void *) glutChangeToMenuEntry },
|
||||
{ "glutChangeToSubMenu", (const void *) glutChangeToSubMenu },
|
||||
{ "glutRemoveMenuItem", (const void *) glutRemoveMenuItem },
|
||||
{ "glutAttachMenu", (const void *) glutAttachMenu },
|
||||
{ "glutDetachMenu", (const void *) glutDetachMenu },
|
||||
{ "glutDisplayFunc", (const void *) glutDisplayFunc },
|
||||
{ "glutReshapeFunc", (const void *) glutReshapeFunc },
|
||||
{ "glutKeyboardFunc", (const void *) glutKeyboardFunc },
|
||||
{ "glutMouseFunc", (const void *) glutMouseFunc },
|
||||
{ "glutMotionFunc", (const void *) glutMotionFunc },
|
||||
{ "glutPassiveMotionFunc", (const void *) glutPassiveMotionFunc },
|
||||
{ "glutEntryFunc", (const void *) glutEntryFunc },
|
||||
{ "glutVisibilityFunc", (const void *) glutVisibilityFunc },
|
||||
{ "glutIdleFunc", (const void *) glutIdleFunc },
|
||||
{ "glutTimerFunc", (const void *) glutTimerFunc },
|
||||
{ "glutMenuStateFunc", (const void *) glutMenuStateFunc },
|
||||
{ "glutSpecialFunc", (const void *) glutSpecialFunc },
|
||||
{ "glutSpaceballMotionFunc", (const void *) glutSpaceballMotionFunc },
|
||||
{ "glutSpaceballRotateFunc", (const void *) glutSpaceballRotateFunc },
|
||||
{ "glutSpaceballButtonFunc", (const void *) glutSpaceballButtonFunc },
|
||||
{ "glutButtonBoxFunc", (const void *) glutButtonBoxFunc },
|
||||
{ "glutDialsFunc", (const void *) glutDialsFunc },
|
||||
{ "glutTabletMotionFunc", (const void *) glutTabletMotionFunc },
|
||||
{ "glutTabletButtonFunc", (const void *) glutTabletButtonFunc },
|
||||
{ "glutMenuStatusFunc", (const void *) glutMenuStatusFunc },
|
||||
{ "glutOverlayDisplayFunc", (const void *) glutOverlayDisplayFunc },
|
||||
{ "glutWindowStatusFunc", (const void *) glutWindowStatusFunc },
|
||||
{ "glutKeyboardUpFunc", (const void *) glutKeyboardUpFunc },
|
||||
{ "glutSpecialUpFunc", (const void *) glutSpecialUpFunc },
|
||||
{ "glutJoystickFunc", (const void *) glutJoystickFunc },
|
||||
{ "glutSetColor", (const void *) glutSetColor },
|
||||
{ "glutGetColor", (const void *) glutGetColor },
|
||||
{ "glutCopyColormap", (const void *) glutCopyColormap },
|
||||
{ "glutGet", (const void *) glutGet },
|
||||
{ "glutDeviceGet", (const void *) glutDeviceGet },
|
||||
{ "glutExtensionSupported", (const void *) glutExtensionSupported },
|
||||
{ "glutGetModifiers", (const void *) glutGetModifiers },
|
||||
{ "glutLayerGet", (const void *) glutLayerGet },
|
||||
{ "glutGetProcAddress", (const void *) glutGetProcAddress },
|
||||
{ "glutBitmapCharacter", (const void *) glutBitmapCharacter },
|
||||
{ "glutBitmapWidth", (const void *) glutBitmapWidth },
|
||||
{ "glutStrokeCharacter", (const void *) glutStrokeCharacter },
|
||||
{ "glutStrokeWidth", (const void *) glutStrokeWidth },
|
||||
{ "glutBitmapLength", (const void *) glutBitmapLength },
|
||||
{ "glutStrokeLength", (const void *) glutStrokeLength },
|
||||
{ "glutWireSphere", (const void *) glutWireSphere },
|
||||
{ "glutSolidSphere", (const void *) glutSolidSphere },
|
||||
{ "glutWireCone", (const void *) glutWireCone },
|
||||
{ "glutSolidCone", (const void *) glutSolidCone },
|
||||
{ "glutWireCube", (const void *) glutWireCube },
|
||||
{ "glutSolidCube", (const void *) glutSolidCube },
|
||||
{ "glutWireTorus", (const void *) glutWireTorus },
|
||||
{ "glutSolidTorus", (const void *) glutSolidTorus },
|
||||
{ "glutWireDodecahedron", (const void *) glutWireDodecahedron },
|
||||
{ "glutSolidDodecahedron", (const void *) glutSolidDodecahedron },
|
||||
{ "glutWireTeapot", (const void *) glutWireTeapot },
|
||||
{ "glutSolidTeapot", (const void *) glutSolidTeapot },
|
||||
{ "glutWireOctahedron", (const void *) glutWireOctahedron },
|
||||
{ "glutSolidOctahedron", (const void *) glutSolidOctahedron },
|
||||
{ "glutWireTetrahedron", (const void *) glutWireTetrahedron },
|
||||
{ "glutSolidTetrahedron", (const void *) glutSolidTetrahedron },
|
||||
{ "glutWireIcosahedron", (const void *) glutWireIcosahedron },
|
||||
{ "glutSolidIcosahedron", (const void *) glutSolidIcosahedron },
|
||||
{ "glutVideoResizeGet", (const void *) glutVideoResizeGet },
|
||||
{ "glutSetupVideoResizing", (const void *) glutSetupVideoResizing },
|
||||
{ "glutStopVideoResizing", (const void *) glutStopVideoResizing },
|
||||
{ "glutVideoResize", (const void *) glutVideoResize },
|
||||
{ "glutVideoPan", (const void *) glutVideoPan },
|
||||
{ "glutReportErrors", (const void *) glutReportErrors },
|
||||
{ "glutIgnoreKeyRepeat", (const void *) glutIgnoreKeyRepeat },
|
||||
{ "glutSetKeyRepeat", (const void *) glutSetKeyRepeat },
|
||||
{ "glutForceJoystickFunc", (const void *) glutForceJoystickFunc },
|
||||
{ "glutGameModeString", (const void *) glutGameModeString },
|
||||
{ "glutEnterGameMode", (const void *) glutEnterGameMode },
|
||||
{ "glutLeaveGameMode", (const void *) glutLeaveGameMode },
|
||||
{ "glutGameModeGet", (const void *) glutGameModeGet },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
/* XXX This isn't an official GLUT function, yet */
|
||||
void * GLUTAPIENTRY
|
||||
glutGetProcAddress(const char *procName)
|
||||
{
|
||||
/* Try GLUT functions first */
|
||||
int i;
|
||||
for (i = 0; glut_functions[i].name; i++) {
|
||||
if (strcmp(glut_functions[i].name, procName) == 0)
|
||||
return (void *) glut_functions[i].address;
|
||||
}
|
||||
|
||||
/* Try core GL functions */
|
||||
#if defined(_WIN32)
|
||||
return (void *) wglGetProcAddress((LPCSTR) procName);
|
||||
|
||||
#elif defined(__OS2PM__)
|
||||
return (void *) wglGetProcAddress((char *) procName);
|
||||
#elif defined(GLX_ARB_get_proc_address)
|
||||
return (void *) glXGetProcAddressARB((const GLubyte *) procName);
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* ENDCENTRY */
|
|
@ -0,0 +1,38 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1995, 1998. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "glutint.h"
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY
|
||||
glutFullScreen(void)
|
||||
{
|
||||
assert(!__glutCurrentWindow->parent);
|
||||
IGNORE_IN_GAME_MODE();
|
||||
#if !defined(_WIN32) && !defined(__OS2PM__)
|
||||
if (__glutMotifHints == None) {
|
||||
__glutMotifHints = XSGIFastInternAtom(__glutDisplay, "_MOTIF_WM_HINTS",
|
||||
SGI_XA__MOTIF_WM_HINTS, 0);
|
||||
if (__glutMotifHints == None) {
|
||||
__glutWarning("Could not intern X atom for _MOTIF_WM_HINTS.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
__glutCurrentWindow->desiredX = 0;
|
||||
__glutCurrentWindow->desiredY = 0;
|
||||
__glutCurrentWindow->desiredWidth = __glutScreenWidth;
|
||||
__glutCurrentWindow->desiredHeight = __glutScreenHeight;
|
||||
__glutCurrentWindow->desiredConfMask |= CWX | CWY | CWWidth | CWHeight;
|
||||
|
||||
__glutPutOnWorkList(__glutCurrentWindow,
|
||||
GLUT_CONFIGURE_WORK | GLUT_FULL_SCREEN_WORK);
|
||||
}
|
||||
|
||||
/* ENDCENTRY */
|
|
@ -0,0 +1,680 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1998. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "glutint.h"
|
||||
|
||||
#if !defined(_WIN32) && !defined(__OS2__)
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
/* SGI optimization introduced in IRIX 6.3 to avoid X server
|
||||
round trips for interning common X atoms. */
|
||||
#if defined(_SGI_EXTRA_PREDEFINES) && !defined(NO_FAST_ATOMS)
|
||||
#include <X11/SGIFastAtom.h>
|
||||
#else
|
||||
#define XSGIFastInternAtom(dpy,string,fast_name,how) XInternAtom(dpy,string,how)
|
||||
#endif
|
||||
#endif /* not _WIN32 */
|
||||
|
||||
int __glutDisplaySettingsChanged = 0;
|
||||
static DisplayMode *dmodes, *currentDm = NULL;
|
||||
static int ndmodes = -1;
|
||||
GLUTwindow *__glutGameModeWindow = NULL;
|
||||
|
||||
#ifdef TEST
|
||||
static char *compstr[] =
|
||||
{
|
||||
"none", "=", "!=", "<=", ">=", ">", "<", "~"
|
||||
};
|
||||
static char *capstr[] =
|
||||
{
|
||||
"width", "height", "bpp", "hertz", "num"
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(__OS2__)
|
||||
void
|
||||
#else
|
||||
void __cdecl
|
||||
#endif
|
||||
__glutCloseDownGameMode(void)
|
||||
{
|
||||
if (__glutDisplaySettingsChanged) {
|
||||
#ifdef _WIN32
|
||||
/* Assumes that display settings have been changed, that
|
||||
is __glutDisplaySettingsChanged is true. */
|
||||
ChangeDisplaySettings(NULL, 0);
|
||||
#endif
|
||||
__glutDisplaySettingsChanged = 0;
|
||||
}
|
||||
__glutGameModeWindow = NULL;
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutLeaveGameMode(void)
|
||||
{
|
||||
if (__glutGameModeWindow == NULL) {
|
||||
__glutWarning("not in game mode so cannot leave game mode");
|
||||
return;
|
||||
}
|
||||
__glutDestroyWindow(__glutGameModeWindow,
|
||||
__glutGameModeWindow);
|
||||
XFlush(__glutDisplay);
|
||||
__glutGameModeWindow = NULL;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
/* Same values as from MSDN's SetDisp.c example. */
|
||||
#define MIN_WIDTH 400
|
||||
#define MIN_FREQUENCY 60
|
||||
|
||||
static void
|
||||
initGameModeSupport(void)
|
||||
{
|
||||
DEVMODE dm;
|
||||
DWORD mode;
|
||||
int i;
|
||||
|
||||
if (ndmodes >= 0) {
|
||||
/* ndmodes is initially -1 to indicate no
|
||||
dmodes allocated yet. */
|
||||
return;
|
||||
}
|
||||
|
||||
/* Determine how many display modes there are. */
|
||||
ndmodes = 0;
|
||||
mode = 0;
|
||||
while (EnumDisplaySettings(NULL, mode, &dm)) {
|
||||
if (dm.dmPelsWidth >= MIN_WIDTH &&
|
||||
(dm.dmDisplayFrequency == 0 ||
|
||||
dm.dmDisplayFrequency >= MIN_FREQUENCY)) {
|
||||
ndmodes++;
|
||||
}
|
||||
mode++;
|
||||
}
|
||||
|
||||
/* Allocate memory for a list of all the display modes. */
|
||||
dmodes = (DisplayMode*)
|
||||
malloc(ndmodes * sizeof(DisplayMode));
|
||||
|
||||
/* Now that we know how many display modes to expect,
|
||||
enumerate them again and save the information in
|
||||
the list we allocated above. */
|
||||
i = 0;
|
||||
mode = 0;
|
||||
while (EnumDisplaySettings(NULL, mode, &dm)) {
|
||||
/* Try to reject any display settings that seem unplausible. */
|
||||
if (dm.dmPelsWidth >= MIN_WIDTH &&
|
||||
(dm.dmDisplayFrequency == 0 ||
|
||||
dm.dmDisplayFrequency >= MIN_FREQUENCY)) {
|
||||
dmodes[i].devmode = dm;
|
||||
dmodes[i].valid = 1; /* XXX Not used for now. */
|
||||
dmodes[i].cap[DM_WIDTH] = dm.dmPelsWidth;
|
||||
dmodes[i].cap[DM_HEIGHT] = dm.dmPelsHeight;
|
||||
dmodes[i].cap[DM_PIXEL_DEPTH] = dm.dmBitsPerPel;
|
||||
if (dm.dmDisplayFrequency == 0) {
|
||||
/* Guess a reasonable guess. */
|
||||
/* Lame Windows 95 version of EnumDisplaySettings. */
|
||||
dmodes[i].cap[DM_HERTZ] = 60;
|
||||
} else {
|
||||
dmodes[i].cap[DM_HERTZ] = dm.dmDisplayFrequency;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
mode++;
|
||||
}
|
||||
|
||||
assert(i == ndmodes);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* X Windows version of initGameModeSupport. */
|
||||
static void
|
||||
initGameModeSupport(void)
|
||||
{
|
||||
if (ndmodes >= 0) {
|
||||
/* ndmodes is initially -1 to indicate no
|
||||
dmodes allocated yet. */
|
||||
return;
|
||||
}
|
||||
|
||||
/* Determine how many display modes there are. */
|
||||
ndmodes = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* This routine is based on similiar code in glut_dstr.c */
|
||||
static DisplayMode *
|
||||
findMatch(DisplayMode * dmodes, int ndmodes,
|
||||
Criterion * criteria, int ncriteria)
|
||||
{
|
||||
DisplayMode *found;
|
||||
int *bestScore, *thisScore;
|
||||
int i, j, numok, result = 0, worse, better;
|
||||
|
||||
found = NULL;
|
||||
numok = 1; /* "num" capability is indexed from 1,
|
||||
not 0. */
|
||||
|
||||
/* XXX alloca canidate. */
|
||||
bestScore = (int *) malloc(ncriteria * sizeof(int));
|
||||
if (!bestScore) {
|
||||
__glutFatalError("out of memory.");
|
||||
}
|
||||
for (j = 0; j < ncriteria; j++) {
|
||||
/* Very negative number. */
|
||||
bestScore[j] = -32768;
|
||||
}
|
||||
|
||||
/* XXX alloca canidate. */
|
||||
thisScore = (int *) malloc(ncriteria * sizeof(int));
|
||||
if (!thisScore) {
|
||||
__glutFatalError("out of memory.");
|
||||
}
|
||||
|
||||
for (i = 0; i < ndmodes; i++) {
|
||||
if (dmodes[i].valid) {
|
||||
worse = 0;
|
||||
better = 0;
|
||||
|
||||
for (j = 0; j < ncriteria; j++) {
|
||||
int cap, cvalue, dvalue;
|
||||
|
||||
cap = criteria[j].capability;
|
||||
cvalue = criteria[j].value;
|
||||
if (cap == NUM) {
|
||||
dvalue = numok;
|
||||
} else {
|
||||
dvalue = dmodes[i].cap[cap];
|
||||
}
|
||||
#ifdef TEST
|
||||
if (verbose)
|
||||
printf(" %s %s %d to %d\n",
|
||||
capstr[cap], compstr[criteria[j].comparison], cvalue, dvalue);
|
||||
#endif
|
||||
switch (criteria[j].comparison) {
|
||||
case EQ:
|
||||
result = cvalue == dvalue;
|
||||
thisScore[j] = 1;
|
||||
break;
|
||||
case NEQ:
|
||||
result = cvalue != dvalue;
|
||||
thisScore[j] = 1;
|
||||
break;
|
||||
case LT:
|
||||
result = dvalue < cvalue;
|
||||
thisScore[j] = dvalue - cvalue;
|
||||
break;
|
||||
case GT:
|
||||
result = dvalue > cvalue;
|
||||
thisScore[j] = dvalue - cvalue;
|
||||
break;
|
||||
case LTE:
|
||||
result = dvalue <= cvalue;
|
||||
thisScore[j] = dvalue - cvalue;
|
||||
break;
|
||||
case GTE:
|
||||
result = (dvalue >= cvalue);
|
||||
thisScore[j] = dvalue - cvalue;
|
||||
break;
|
||||
case MIN:
|
||||
result = dvalue >= cvalue;
|
||||
thisScore[j] = cvalue - dvalue;
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
if (verbose)
|
||||
printf(" result=%d score=%d bestScore=%d\n", result, thisScore[j], bestScore[j]);
|
||||
#endif
|
||||
|
||||
if (result) {
|
||||
if (better || thisScore[j] > bestScore[j]) {
|
||||
better = 1;
|
||||
} else if (thisScore[j] == bestScore[j]) {
|
||||
/* Keep looking. */
|
||||
} else {
|
||||
goto nextDM;
|
||||
}
|
||||
} else {
|
||||
if (cap == NUM) {
|
||||
worse = 1;
|
||||
} else {
|
||||
goto nextDM;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (better && !worse) {
|
||||
found = &dmodes[i];
|
||||
for (j = 0; j < ncriteria; j++) {
|
||||
bestScore[j] = thisScore[j];
|
||||
}
|
||||
}
|
||||
numok++;
|
||||
|
||||
nextDM:;
|
||||
|
||||
}
|
||||
}
|
||||
free(bestScore);
|
||||
free(thisScore);
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses strings in the form of:
|
||||
* 800x600
|
||||
* 800x600:16
|
||||
* 800x600@60
|
||||
* 800x600:16@60
|
||||
* @60
|
||||
* :16
|
||||
* :16@60
|
||||
* NOTE that @ before : is not parsed.
|
||||
*/
|
||||
static int
|
||||
specialCaseParse(char *word, Criterion * criterion, int mask)
|
||||
{
|
||||
char *xstr, *response;
|
||||
int got;
|
||||
int width, height, bpp, hertz;
|
||||
|
||||
switch(word[0]) {
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
/* The WWWxHHH case. */
|
||||
if (mask & (1 << DM_WIDTH)) {
|
||||
return -1;
|
||||
}
|
||||
xstr = strpbrk(&word[1], "x");
|
||||
if (xstr) {
|
||||
width = (int) strtol(word, &response, 0);
|
||||
if (response == word || response[0] != 'x') {
|
||||
/* Not a valid number OR needs to be followed by 'x'. */
|
||||
return -1;
|
||||
}
|
||||
height = (int) strtol(&xstr[1], &response, 0);
|
||||
if (response == &xstr[1]) {
|
||||
/* Not a valid number. */
|
||||
return -1;
|
||||
}
|
||||
criterion[0].capability = DM_WIDTH;
|
||||
criterion[0].comparison = EQ;
|
||||
criterion[0].value = width;
|
||||
criterion[1].capability = DM_HEIGHT;
|
||||
criterion[1].comparison = EQ;
|
||||
criterion[1].value = height;
|
||||
got = specialCaseParse(response,
|
||||
&criterion[2], 1 << DM_WIDTH);
|
||||
if (got >= 0) {
|
||||
return got + 2;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
case ':':
|
||||
/* The :BPP case. */
|
||||
if (mask & (1 << DM_PIXEL_DEPTH)) {
|
||||
return -1;
|
||||
}
|
||||
bpp = (int) strtol(&word[1], &response, 0);
|
||||
if (response == &word[1]) {
|
||||
/* Not a valid number. */
|
||||
return -1;
|
||||
}
|
||||
criterion[0].capability = DM_PIXEL_DEPTH;
|
||||
criterion[0].comparison = EQ;
|
||||
criterion[0].value = bpp;
|
||||
got = specialCaseParse(response,
|
||||
&criterion[1], (1 << DM_WIDTH) | (1 << DM_PIXEL_DEPTH));
|
||||
if (got >= 0) {
|
||||
return got + 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
case '@':
|
||||
/* The @HZ case. */
|
||||
if (mask & (1 << DM_HERTZ)) {
|
||||
return -1;
|
||||
}
|
||||
hertz = (int) strtol(&word[1], &response, 0);
|
||||
if (response == &word[1]) {
|
||||
/* Not a valid number. */
|
||||
return -1;
|
||||
}
|
||||
criterion[0].capability = DM_HERTZ;
|
||||
criterion[0].comparison = EQ;
|
||||
criterion[0].value = hertz;
|
||||
got = specialCaseParse(response,
|
||||
&criterion[1], ~DM_HERTZ);
|
||||
if (got >= 0) {
|
||||
return got + 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
case '\0':
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* This routine is based on similiar code in glut_dstr.c */
|
||||
static int
|
||||
parseCriteria(char *word, Criterion * criterion)
|
||||
{
|
||||
char *cstr, *vstr, *response;
|
||||
int comparator, value = 0;
|
||||
|
||||
cstr = strpbrk(word, "=><!~");
|
||||
if (cstr) {
|
||||
switch (cstr[0]) {
|
||||
case '=':
|
||||
comparator = EQ;
|
||||
vstr = &cstr[1];
|
||||
break;
|
||||
case '~':
|
||||
comparator = MIN;
|
||||
vstr = &cstr[1];
|
||||
break;
|
||||
case '>':
|
||||
if (cstr[1] == '=') {
|
||||
comparator = GTE;
|
||||
vstr = &cstr[2];
|
||||
} else {
|
||||
comparator = GT;
|
||||
vstr = &cstr[1];
|
||||
}
|
||||
break;
|
||||
case '<':
|
||||
if (cstr[1] == '=') {
|
||||
comparator = LTE;
|
||||
vstr = &cstr[2];
|
||||
} else {
|
||||
comparator = LT;
|
||||
vstr = &cstr[1];
|
||||
}
|
||||
break;
|
||||
case '!':
|
||||
if (cstr[1] == '=') {
|
||||
comparator = NEQ;
|
||||
vstr = &cstr[2];
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
value = (int) strtol(vstr, &response, 0);
|
||||
if (response == vstr) {
|
||||
/* Not a valid number. */
|
||||
return -1;
|
||||
}
|
||||
*cstr = '\0';
|
||||
} else {
|
||||
comparator = NONE;
|
||||
}
|
||||
switch (word[0]) {
|
||||
case 'b':
|
||||
if (!strcmp(word, "bpp")) {
|
||||
criterion[0].capability = DM_PIXEL_DEPTH;
|
||||
if (comparator == NONE) {
|
||||
return -1;
|
||||
} else {
|
||||
criterion[0].comparison = comparator;
|
||||
criterion[0].value = value;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
case 'h':
|
||||
if (!strcmp(word, "height")) {
|
||||
criterion[0].capability = DM_HEIGHT;
|
||||
if (comparator == NONE) {
|
||||
return -1;
|
||||
} else {
|
||||
criterion[0].comparison = comparator;
|
||||
criterion[0].value = value;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (!strcmp(word, "hertz")) {
|
||||
criterion[0].capability = DM_HERTZ;
|
||||
if (comparator == NONE) {
|
||||
return -1;
|
||||
} else {
|
||||
criterion[0].comparison = comparator;
|
||||
criterion[0].value = value;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
case 'n':
|
||||
if (!strcmp(word, "num")) {
|
||||
criterion[0].capability = DM_NUM;
|
||||
if (comparator == NONE) {
|
||||
return -1;
|
||||
} else {
|
||||
criterion[0].comparison = comparator;
|
||||
criterion[0].value = value;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
case 'w':
|
||||
if (!strcmp(word, "width")) {
|
||||
criterion[0].capability = DM_WIDTH;
|
||||
if (comparator == NONE) {
|
||||
return -1;
|
||||
} else {
|
||||
criterion[0].comparison = comparator;
|
||||
criterion[0].value = value;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
if (comparator == NONE) {
|
||||
return specialCaseParse(word, criterion, 0);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* This routine is based on similiar code in glut_dstr.c */
|
||||
static Criterion *
|
||||
parseDisplayString(const char *display, int *ncriteria)
|
||||
{
|
||||
Criterion *criteria = NULL;
|
||||
int n, parsed;
|
||||
char *copy, *word;
|
||||
|
||||
copy = __glutStrdup(display);
|
||||
/* Attempt to estimate how many criteria entries should be
|
||||
needed. */
|
||||
n = 0;
|
||||
word = strtok(copy, " \t");
|
||||
while (word) {
|
||||
n++;
|
||||
word = strtok(NULL, " \t");
|
||||
}
|
||||
/* Allocate number of words of criteria. A word
|
||||
could contain as many as four criteria in the
|
||||
worst case. Example: 800x600:16@60 */
|
||||
criteria = (Criterion *) malloc(4 * n * sizeof(Criterion));
|
||||
if (!criteria) {
|
||||
__glutFatalError("out of memory.");
|
||||
}
|
||||
|
||||
/* Re-copy the copy of the display string. */
|
||||
strcpy(copy, display);
|
||||
|
||||
n = 0;
|
||||
word = strtok(copy, " \t");
|
||||
while (word) {
|
||||
parsed = parseCriteria(word, &criteria[n]);
|
||||
if (parsed >= 0) {
|
||||
n += parsed;
|
||||
} else {
|
||||
__glutWarning("Unrecognized game mode string word: %s (ignoring)\n", word);
|
||||
}
|
||||
word = strtok(NULL, " \t");
|
||||
}
|
||||
|
||||
free(copy);
|
||||
*ncriteria = n;
|
||||
return criteria;
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutGameModeString(const char *string)
|
||||
{
|
||||
Criterion *criteria;
|
||||
int ncriteria;
|
||||
|
||||
initGameModeSupport();
|
||||
criteria = parseDisplayString(string, &ncriteria);
|
||||
currentDm = findMatch(dmodes, ndmodes, criteria, ncriteria);
|
||||
free(criteria);
|
||||
}
|
||||
|
||||
int GLUTAPIENTRY
|
||||
glutEnterGameMode(void)
|
||||
{
|
||||
GLUTwindow *window;
|
||||
int width, height;
|
||||
Window win;
|
||||
|
||||
if (__glutMappedMenu) {
|
||||
__glutFatalUsage("entering game mode not allowed while menus in use");
|
||||
}
|
||||
if (__glutGameModeWindow) {
|
||||
/* Already in game mode, so blow away game mode
|
||||
window so apps can change resolutions. */
|
||||
window = __glutGameModeWindow;
|
||||
/* Setting the game mode window to NULL tricks
|
||||
the window destroy code into not undoing the
|
||||
screen display change since we plan on immediately
|
||||
doing another mode change. */
|
||||
__glutGameModeWindow = NULL;
|
||||
__glutDestroyWindow(window, window);
|
||||
}
|
||||
|
||||
/* Assume default screen size until we find out if we
|
||||
can actually change the display settings. */
|
||||
width = __glutScreenWidth;
|
||||
height = __glutScreenHeight;
|
||||
|
||||
if (currentDm) {
|
||||
#ifdef _WIN32
|
||||
LONG status;
|
||||
static int registered = 0;
|
||||
|
||||
status = ChangeDisplaySettings(¤tDm->devmode,
|
||||
CDS_FULLSCREEN);
|
||||
if (status == DISP_CHANGE_SUCCESSFUL) {
|
||||
__glutDisplaySettingsChanged = 1;
|
||||
width = currentDm->cap[DM_WIDTH];
|
||||
height = currentDm->cap[DM_HEIGHT];
|
||||
if (!registered) {
|
||||
atexit(__glutCloseDownGameMode);
|
||||
registered = 1;
|
||||
}
|
||||
} else {
|
||||
/* Switch back to default resolution. */
|
||||
ChangeDisplaySettings(NULL, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
window = __glutCreateWindow(NULL, 0, 0,
|
||||
width, height, /* game mode */ 1);
|
||||
win = window->win;
|
||||
|
||||
#if !defined(_WIN32) && !defined(__OS2__)
|
||||
if (__glutMotifHints == None) {
|
||||
__glutMotifHints = XSGIFastInternAtom(__glutDisplay, "_MOTIF_WM_HINTS",
|
||||
SGI_XA__MOTIF_WM_HINTS, 0);
|
||||
if (__glutMotifHints == None) {
|
||||
__glutWarning("Could not intern X atom for _MOTIF_WM_HINTS.");
|
||||
}
|
||||
}
|
||||
|
||||
/* Game mode window is a toplevel window. */
|
||||
XSetWMProtocols(__glutDisplay, win, &__glutWMDeleteWindow, 1);
|
||||
#endif
|
||||
|
||||
/* Schedule the fullscreen property to be added and to
|
||||
make sure the window is configured right. Win32
|
||||
doesn't need this. */
|
||||
window->desiredX = 0;
|
||||
window->desiredY = 0;
|
||||
window->desiredWidth = width;
|
||||
window->desiredHeight = height;
|
||||
window->desiredConfMask |= CWX | CWY | CWWidth | CWHeight;
|
||||
#ifdef _WIN32
|
||||
/* Win32 does not want to use GLUT_FULL_SCREEN_WORK
|
||||
for game mode because we need to be maximizing
|
||||
the window in game mode, not just sizing it to
|
||||
take up the full screen. The Win32-ness of game
|
||||
mode happens when you pass 1 in the gameMode parameter
|
||||
to __glutCreateWindow above. A gameMode of creates
|
||||
a WS_POPUP window, not a standard WS_OVERLAPPEDWINDOW
|
||||
window. WS_POPUP ensures the taskbar is hidden. */
|
||||
__glutPutOnWorkList(window,
|
||||
GLUT_CONFIGURE_WORK);
|
||||
#else
|
||||
__glutPutOnWorkList(window,
|
||||
GLUT_CONFIGURE_WORK | GLUT_FULL_SCREEN_WORK);
|
||||
#endif
|
||||
|
||||
__glutGameModeWindow = window;
|
||||
return window->num + 1;
|
||||
}
|
||||
|
||||
int GLUTAPIENTRY
|
||||
glutGameModeGet(GLenum mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case GLUT_GAME_MODE_ACTIVE:
|
||||
return __glutGameModeWindow != NULL;
|
||||
case GLUT_GAME_MODE_POSSIBLE:
|
||||
return currentDm != NULL;
|
||||
case GLUT_GAME_MODE_WIDTH:
|
||||
return currentDm ? currentDm->cap[DM_WIDTH] : -1;
|
||||
case GLUT_GAME_MODE_HEIGHT:
|
||||
return currentDm ? currentDm->cap[DM_HEIGHT] : -1;
|
||||
case GLUT_GAME_MODE_PIXEL_DEPTH:
|
||||
return currentDm ? currentDm->cap[DM_PIXEL_DEPTH] : -1;
|
||||
case GLUT_GAME_MODE_REFRESH_RATE:
|
||||
return currentDm ? currentDm->cap[DM_HERTZ] : -1;
|
||||
case GLUT_GAME_MODE_DISPLAY_CHANGED:
|
||||
return __glutDisplaySettingsChanged;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,232 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1994, 1997, 1998. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h> /* SunOS 4 needs NULL defined for GETTIMEOFDAY macro. */
|
||||
#include "glutint.h"
|
||||
|
||||
/* CENTRY */
|
||||
int GLUTAPIENTRY
|
||||
glutGet(GLenum param)
|
||||
{
|
||||
Window win, root;
|
||||
int x, y, value;
|
||||
unsigned int width, height, border, depth;
|
||||
|
||||
switch (param) {
|
||||
case GLUT_INIT_WINDOW_X:
|
||||
return __glutInitX;
|
||||
case GLUT_INIT_WINDOW_Y:
|
||||
return __glutInitY;
|
||||
case GLUT_INIT_WINDOW_WIDTH:
|
||||
return __glutInitWidth;
|
||||
case GLUT_INIT_WINDOW_HEIGHT:
|
||||
return __glutInitHeight;
|
||||
case GLUT_INIT_DISPLAY_MODE:
|
||||
return __glutDisplayMode;
|
||||
case GLUT_WINDOW_X:
|
||||
XTranslateCoordinates(__glutDisplay, __glutCurrentWindow->win,
|
||||
__glutRoot, 0, 0, &x, &y, &win);
|
||||
return x;
|
||||
case GLUT_WINDOW_Y:
|
||||
XTranslateCoordinates(__glutDisplay, __glutCurrentWindow->win,
|
||||
__glutRoot, 0, 0, &x, &y, &win);
|
||||
return y;
|
||||
case GLUT_WINDOW_WIDTH:
|
||||
if (!__glutCurrentWindow->reshape) {
|
||||
XGetGeometry(__glutDisplay, __glutCurrentWindow->win,
|
||||
&root, &x, &y,
|
||||
&width, &height, &border, &depth);
|
||||
return width;
|
||||
}
|
||||
return __glutCurrentWindow->width;
|
||||
case GLUT_WINDOW_HEIGHT:
|
||||
if (!__glutCurrentWindow->reshape) {
|
||||
XGetGeometry(__glutDisplay, __glutCurrentWindow->win,
|
||||
&root, &x, &y,
|
||||
&width, &height, &border, &depth);
|
||||
return height;
|
||||
}
|
||||
return __glutCurrentWindow->height;
|
||||
#ifdef __OS2__
|
||||
#define GET_CONFIG(attrib) \
|
||||
{ if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) \
|
||||
glXGetConfig( __glutCurrentWindow->vis, attrib, &value); \
|
||||
else \
|
||||
glXGetConfig(__glutCurrentWindow->overlay->vis, attrib, &value); \
|
||||
} \
|
||||
|
||||
#else
|
||||
|
||||
#define GET_CONFIG(attrib) { \
|
||||
if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) { \
|
||||
glXGetConfig(__glutDisplay, __glutCurrentWindow->vis, \
|
||||
attrib, &value); \
|
||||
} else { \
|
||||
glXGetConfig(__glutDisplay, __glutCurrentWindow->overlay->vis, \
|
||||
attrib, &value); \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
case GLUT_WINDOW_BUFFER_SIZE:
|
||||
GET_CONFIG(GLX_BUFFER_SIZE);
|
||||
return value;
|
||||
case GLUT_WINDOW_STENCIL_SIZE:
|
||||
GET_CONFIG(GLX_STENCIL_SIZE);
|
||||
return value;
|
||||
case GLUT_WINDOW_DEPTH_SIZE:
|
||||
GET_CONFIG(GLX_DEPTH_SIZE);
|
||||
return value;
|
||||
case GLUT_WINDOW_RED_SIZE:
|
||||
GET_CONFIG(GLX_RED_SIZE);
|
||||
return value;
|
||||
case GLUT_WINDOW_GREEN_SIZE:
|
||||
GET_CONFIG(GLX_GREEN_SIZE);
|
||||
return value;
|
||||
case GLUT_WINDOW_BLUE_SIZE:
|
||||
GET_CONFIG(GLX_BLUE_SIZE);
|
||||
return value;
|
||||
case GLUT_WINDOW_ALPHA_SIZE:
|
||||
GET_CONFIG(GLX_ALPHA_SIZE);
|
||||
return value;
|
||||
case GLUT_WINDOW_ACCUM_RED_SIZE:
|
||||
GET_CONFIG(GLX_ACCUM_RED_SIZE);
|
||||
return value;
|
||||
case GLUT_WINDOW_ACCUM_GREEN_SIZE:
|
||||
GET_CONFIG(GLX_ACCUM_GREEN_SIZE);
|
||||
return value;
|
||||
case GLUT_WINDOW_ACCUM_BLUE_SIZE:
|
||||
GET_CONFIG(GLX_ACCUM_BLUE_SIZE);
|
||||
return value;
|
||||
case GLUT_WINDOW_ACCUM_ALPHA_SIZE:
|
||||
GET_CONFIG(GLX_ACCUM_ALPHA_SIZE);
|
||||
return value;
|
||||
case GLUT_WINDOW_DOUBLEBUFFER:
|
||||
GET_CONFIG(GLX_DOUBLEBUFFER);
|
||||
return value;
|
||||
case GLUT_WINDOW_RGBA:
|
||||
GET_CONFIG(GLX_RGBA);
|
||||
return value;
|
||||
case GLUT_WINDOW_COLORMAP_SIZE:
|
||||
GET_CONFIG(GLX_RGBA);
|
||||
if (value) {
|
||||
return 0;
|
||||
} else {
|
||||
#if defined(_WIN32) || defined(__OS2__)
|
||||
/* KLUDGE: we always assume 256 colors in CI mode on
|
||||
Win32 */
|
||||
return 256;
|
||||
#else
|
||||
if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
|
||||
return __glutCurrentWindow->vis->visual->map_entries;
|
||||
} else {
|
||||
return __glutCurrentWindow->overlay->vis->visual->map_entries;
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
case GLUT_WINDOW_PARENT:
|
||||
return __glutCurrentWindow->parent ?
|
||||
__glutCurrentWindow->parent->num + 1 : 0;
|
||||
case GLUT_WINDOW_NUM_CHILDREN:
|
||||
{
|
||||
int num = 0;
|
||||
GLUTwindow *children = __glutCurrentWindow->children;
|
||||
|
||||
while (children) {
|
||||
num++;
|
||||
children = children->siblings;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
case GLUT_WINDOW_NUM_SAMPLES:
|
||||
#if defined(GLX_VERSION_1_1) && defined(GLX_SGIS_multisample)
|
||||
if (__glutIsSupportedByGLX("GLX_SGIS_multisample")) {
|
||||
GET_CONFIG(GLX_SAMPLES_SGIS);
|
||||
return value;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
/* Independent of GLX server support, multisampling not
|
||||
supported by GLX client-side. */
|
||||
return 0;
|
||||
#endif
|
||||
case GLUT_WINDOW_STEREO:
|
||||
GET_CONFIG(GLX_STEREO);
|
||||
return value;
|
||||
case GLUT_WINDOW_CURSOR:
|
||||
return __glutCurrentWindow->cursor;
|
||||
case GLUT_SCREEN_WIDTH:
|
||||
return DisplayWidth(__glutDisplay, __glutScreen);
|
||||
case GLUT_SCREEN_HEIGHT:
|
||||
return DisplayHeight(__glutDisplay, __glutScreen);
|
||||
case GLUT_SCREEN_WIDTH_MM:
|
||||
return DisplayWidthMM(__glutDisplay, __glutScreen);
|
||||
case GLUT_SCREEN_HEIGHT_MM:
|
||||
return DisplayHeightMM(__glutDisplay, __glutScreen);
|
||||
case GLUT_MENU_NUM_ITEMS:
|
||||
return __glutCurrentMenu->num;
|
||||
case GLUT_DISPLAY_MODE_POSSIBLE:
|
||||
{
|
||||
XVisualInfo *vi;
|
||||
Bool dummy, visAlloced;
|
||||
void *fbc;
|
||||
|
||||
#if defined(_WIN32)
|
||||
/* Our fake glXChooseVisual (which is called by
|
||||
__glutDetermineVisual) needs an HDC to work with, so grab one
|
||||
from the "root" window. */
|
||||
XHDC = GetDC(GetDesktopWindow());
|
||||
#endif
|
||||
vi = __glutDetermineWindowVisual(&dummy, &visAlloced, &fbc);
|
||||
#if defined(_WIN32)
|
||||
ReleaseDC(GetDesktopWindow(), XHDC);
|
||||
#endif
|
||||
if (vi) {
|
||||
if (visAlloced)
|
||||
XFree(vi);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
case GLUT_ELAPSED_TIME:
|
||||
{
|
||||
#ifdef OLD_VMS
|
||||
struct timeval6 elapsed, beginning, now;
|
||||
#else
|
||||
struct timeval elapsed, beginning, now;
|
||||
#endif
|
||||
|
||||
__glutInitTime(&beginning);
|
||||
GETTIMEOFDAY(&now);
|
||||
TIMEDELTA(elapsed, now, beginning);
|
||||
/* Return elapsed milliseconds. */
|
||||
#if defined(__vms) && ( __VMS_VER < 70000000 )
|
||||
return (int) (elapsed.val / TICKS_PER_MILLISECOND);
|
||||
#else
|
||||
return (int) ((elapsed.tv_sec * 1000) + (elapsed.tv_usec / 1000));
|
||||
#endif
|
||||
}
|
||||
case GLUT_WINDOW_FORMAT_ID:
|
||||
#if defined(__OS2__)
|
||||
return wglGetPixelFormat(__glutCurrentWindow->hdc);
|
||||
#elif defined(_WIN32)
|
||||
return GetPixelFormat(__glutCurrentWindow->hdc);
|
||||
#else
|
||||
if (__glutCurrentWindow->renderWin == __glutCurrentWindow->win) {
|
||||
return (int) __glutCurrentWindow->vis->visualid;
|
||||
} else {
|
||||
return (int) __glutCurrentWindow->overlay->vis->visualid;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
__glutWarning("invalid glutGet parameter: %d", param);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/* ENDCENTRY */
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,451 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1994, 1997. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#ifdef __VMS
|
||||
#include <GL/vms_x_fix.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if !defined(_WIN32) && !defined(__OS2__)
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#endif
|
||||
|
||||
/* SGI optimization introduced in IRIX 6.3 to avoid X server
|
||||
round trips for interning common X atoms. */
|
||||
#if defined(_SGI_EXTRA_PREDEFINES) && !defined(NO_FAST_ATOMS)
|
||||
#include <X11/SGIFastAtom.h>
|
||||
#else
|
||||
#define XSGIFastInternAtom(dpy,string,fast_name,how) XInternAtom(dpy,string,how)
|
||||
#endif
|
||||
|
||||
#include "glutint.h"
|
||||
|
||||
/* GLUT inter-file variables */
|
||||
/* *INDENT-OFF* */
|
||||
char *__glutProgramName = NULL;
|
||||
int __glutArgc = 0;
|
||||
char **__glutArgv = NULL;
|
||||
char *__glutGeometry = NULL;
|
||||
Display *__glutDisplay = NULL;
|
||||
int __glutScreen;
|
||||
Window __glutRoot;
|
||||
int __glutScreenHeight;
|
||||
int __glutScreenWidth;
|
||||
GLboolean __glutIconic = GL_FALSE;
|
||||
GLboolean __glutDebug = GL_FALSE;
|
||||
unsigned int __glutDisplayMode =
|
||||
GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH;
|
||||
char *__glutDisplayString = NULL;
|
||||
int __glutConnectionFD;
|
||||
XSizeHints __glutSizeHints = {0};
|
||||
int __glutInitWidth = 300, __glutInitHeight = 300;
|
||||
int __glutInitX = -1, __glutInitY = -1;
|
||||
GLboolean __glutForceDirect = GL_FALSE,
|
||||
__glutTryDirect = GL_TRUE;
|
||||
Atom __glutWMDeleteWindow;
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#ifdef _WIN32
|
||||
void (__cdecl *__glutExitFunc)(int retval) = NULL;
|
||||
#endif
|
||||
|
||||
static Bool synchronize = False;
|
||||
|
||||
#if defined(__OS2__)
|
||||
|
||||
MRESULT EXPENTRY GlutWindowProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
|
||||
MRESULT EXPENTRY GlutWindowChildProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
|
||||
|
||||
|
||||
void __glutOpenOS2Connection(char* display)
|
||||
{
|
||||
static char *classname=NULL;
|
||||
extern HAB hab; /* PM anchor block handle */
|
||||
ERRORID erridErrorCode;/* last error id code */
|
||||
int ii;
|
||||
|
||||
/* Make sure we register the window only once. */
|
||||
if(classname)
|
||||
return;
|
||||
|
||||
classname = "GLUT";
|
||||
|
||||
if ( !WinRegisterClass( hab, /* PM anchor block handle */
|
||||
classname,/* window class name */
|
||||
GlutWindowProc,/* address of window procedure*/
|
||||
CS_SIZEREDRAW, /* |CS_SYNCPAINT size changes cause redrawing */
|
||||
0UL ) ) /* window data */
|
||||
{ erridErrorCode = WinGetLastError(hab);
|
||||
ii = erridErrorCode;
|
||||
return;
|
||||
}
|
||||
|
||||
classname = "GLUTCHILD";
|
||||
|
||||
if ( !WinRegisterClass( hab, /* PM anchor block handle */
|
||||
classname,/* window class name */
|
||||
GlutWindowChildProc,/* address of window procedure*/
|
||||
CS_SIZEREDRAW, /* size changes cause redrawing */
|
||||
0UL ) ) /* window data */
|
||||
{ erridErrorCode = WinGetLastError(hab);
|
||||
ii = erridErrorCode;
|
||||
return;
|
||||
}
|
||||
|
||||
__glutScreenWidth = GetSystemMetrics(SM_CXSCREEN);
|
||||
__glutScreenHeight = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
/* Set the root window to NULL because windows creates a top-level
|
||||
window when the parent is NULL. X creates a top-level window
|
||||
when the parent is the root window. */
|
||||
__glutRoot = NULLHANDLE;
|
||||
|
||||
/* Set the display to 1 -- we shouldn't be using this anywhere
|
||||
(except as an argument to X calls). */
|
||||
__glutDisplay = (Display*)1;
|
||||
|
||||
/* There isn't any concept of multiple screens in Win32, therefore,
|
||||
we don't need to keep track of the screen we're on... it's always
|
||||
the same one. */
|
||||
__glutScreen = 0;
|
||||
}
|
||||
|
||||
#elif defined(_WIN32)
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#include <float.h> /* For masking floating point exceptions. */
|
||||
#endif
|
||||
|
||||
void
|
||||
__glutOpenWin32Connection(char* display)
|
||||
{
|
||||
static char *classname;
|
||||
WNDCLASS wc;
|
||||
HINSTANCE hInstance = GetModuleHandle(NULL);
|
||||
|
||||
/* Make sure we register the window only once. */
|
||||
if(classname)
|
||||
return;
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
/* Under certain conditions (e.g. while rendering solid surfaces with
|
||||
lighting enabled) Microsoft OpenGL libraries cause some illegal
|
||||
operations like floating point overflow or division by zero. The
|
||||
default behaviour of Microsoft compilers is to mask (ignore)
|
||||
floating point exceptions, while Borland compilers do not. The
|
||||
following function of Borland RTL allows to mask exceptions.
|
||||
Advice from Pier Giorgio Esposito (mc2172@mclink.it). */
|
||||
_control87(MCW_EM,MCW_EM);
|
||||
#endif
|
||||
|
||||
classname = "GLUT";
|
||||
|
||||
/* Clear (important!) and then fill in the window class structure. */
|
||||
memset(&wc, 0, sizeof(WNDCLASS));
|
||||
wc.style = CS_OWNDC;
|
||||
wc.lpfnWndProc = (WNDPROC)__glutWindowProc;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(hInstance, "GLUT_ICON");
|
||||
wc.hCursor = LoadCursor(hInstance, IDC_ARROW);
|
||||
wc.hbrBackground = NULL;
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = classname;
|
||||
|
||||
/* Fill in a default icon if one isn't specified as a resource. */
|
||||
if(!wc.hIcon)
|
||||
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
|
||||
|
||||
if(!RegisterClass(&wc)) {
|
||||
__glutFatalError("RegisterClass() failed:"
|
||||
"Cannot register GLUT window class.");
|
||||
}
|
||||
|
||||
__glutScreenWidth = GetSystemMetrics(SM_CXSCREEN);
|
||||
__glutScreenHeight = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
/* Set the root window to NULL because windows creates a top-level
|
||||
window when the parent is NULL. X creates a top-level window
|
||||
when the parent is the root window. */
|
||||
__glutRoot = NULL;
|
||||
|
||||
/* Set the display to 1 -- we shouldn't be using this anywhere
|
||||
(except as an argument to X calls). */
|
||||
__glutDisplay = (Display*)1;
|
||||
|
||||
/* There isn't any concept of multiple screens in Win32, therefore,
|
||||
we don't need to keep track of the screen we're on... it's always
|
||||
the same one. */
|
||||
__glutScreen = 0;
|
||||
}
|
||||
#else /* !_WIN32 */
|
||||
void
|
||||
__glutOpenXConnection(char *display)
|
||||
{
|
||||
int errorBase, eventBase;
|
||||
|
||||
__glutDisplay = XOpenDisplay(display);
|
||||
if (!__glutDisplay)
|
||||
__glutFatalError("could not open display: %s",
|
||||
XDisplayName(display));
|
||||
if (synchronize)
|
||||
XSynchronize(__glutDisplay, True);
|
||||
if (!glXQueryExtension(__glutDisplay, &errorBase, &eventBase))
|
||||
__glutFatalError(
|
||||
"OpenGL GLX extension not supported by display: %s",
|
||||
XDisplayName(display));
|
||||
__glutScreen = DefaultScreen(__glutDisplay);
|
||||
__glutRoot = RootWindow(__glutDisplay, __glutScreen);
|
||||
__glutScreenWidth = DisplayWidth(__glutDisplay, __glutScreen);
|
||||
__glutScreenHeight = DisplayHeight(__glutDisplay,
|
||||
__glutScreen);
|
||||
__glutConnectionFD = ConnectionNumber(__glutDisplay);
|
||||
__glutWMDeleteWindow = XSGIFastInternAtom(__glutDisplay,
|
||||
"WM_DELETE_WINDOW", SGI_XA_WM_DELETE_WINDOW, False);
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
void
|
||||
#ifdef OLD_VMS
|
||||
__glutInitTime(struct timeval6 *beginning)
|
||||
#else
|
||||
__glutInitTime(struct timeval *beginning)
|
||||
#endif
|
||||
{
|
||||
static int beenhere = 0;
|
||||
#ifdef OLD_VMS
|
||||
static struct timeval6 genesis;
|
||||
#else
|
||||
static struct timeval genesis;
|
||||
#endif
|
||||
|
||||
if (!beenhere) {
|
||||
GETTIMEOFDAY(&genesis);
|
||||
beenhere = 1;
|
||||
}
|
||||
*beginning = genesis;
|
||||
}
|
||||
|
||||
static void
|
||||
removeArgs(int *argcp, char **argv, int numToRemove)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for (i = 0, j = numToRemove; argv[j]; i++, j++) {
|
||||
argv[i] = argv[j];
|
||||
}
|
||||
argv[i] = NULL;
|
||||
*argcp -= numToRemove;
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutInit(int *argcp, char **argv)
|
||||
{
|
||||
char *display = NULL;
|
||||
char *str, *geometry = NULL;
|
||||
#ifdef OLD_VMS
|
||||
struct timeval6 unused;
|
||||
#else
|
||||
struct timeval unused;
|
||||
#endif
|
||||
int i;
|
||||
|
||||
if (__glutDisplay) {
|
||||
__glutWarning("glutInit being called a second time.");
|
||||
return;
|
||||
}
|
||||
/* Determine temporary program name. */
|
||||
str = strrchr(argv[0], '/');
|
||||
if (str == NULL) {
|
||||
__glutProgramName = argv[0];
|
||||
} else {
|
||||
__glutProgramName = str + 1;
|
||||
}
|
||||
|
||||
/* Make private copy of command line arguments. */
|
||||
__glutArgc = *argcp;
|
||||
__glutArgv = (char **) malloc(__glutArgc * sizeof(char *));
|
||||
if (!__glutArgv)
|
||||
__glutFatalError("out of memory.");
|
||||
for (i = 0; i < __glutArgc; i++) {
|
||||
__glutArgv[i] = __glutStrdup(argv[i]);
|
||||
if (!__glutArgv[i])
|
||||
__glutFatalError("out of memory.");
|
||||
}
|
||||
|
||||
/* determine permanent program name */
|
||||
str = strrchr(__glutArgv[0], '/');
|
||||
if (str == NULL) {
|
||||
__glutProgramName = __glutArgv[0];
|
||||
} else {
|
||||
__glutProgramName = str + 1;
|
||||
}
|
||||
|
||||
/* parse arguments for standard options */
|
||||
for (i = 1; i < __glutArgc; i++) {
|
||||
if (!strcmp(__glutArgv[i], "-display")) {
|
||||
#if defined(_WIN32)
|
||||
__glutWarning("-display option not supported by Win32 GLUT.");
|
||||
#endif
|
||||
if (++i >= __glutArgc) {
|
||||
__glutFatalError(
|
||||
"follow -display option with X display name.");
|
||||
}
|
||||
display = __glutArgv[i];
|
||||
removeArgs(argcp, &argv[1], 2);
|
||||
} else if (!strcmp(__glutArgv[i], "-geometry")) {
|
||||
if (++i >= __glutArgc) {
|
||||
__glutFatalError(
|
||||
"follow -geometry option with geometry parameter.");
|
||||
}
|
||||
geometry = __glutArgv[i];
|
||||
removeArgs(argcp, &argv[1], 2);
|
||||
} else if (!strcmp(__glutArgv[i], "-direct")) {
|
||||
#if defined(_WIN32)
|
||||
__glutWarning("-direct option not supported by Win32 GLUT.");
|
||||
#endif
|
||||
if (!__glutTryDirect)
|
||||
__glutFatalError(
|
||||
"cannot force both direct and indirect rendering.");
|
||||
__glutForceDirect = GL_TRUE;
|
||||
removeArgs(argcp, &argv[1], 1);
|
||||
} else if (!strcmp(__glutArgv[i], "-indirect")) {
|
||||
#if defined(_WIN32)
|
||||
__glutWarning("-indirect option not supported by Win32 GLUT.");
|
||||
#endif
|
||||
if (__glutForceDirect)
|
||||
__glutFatalError(
|
||||
"cannot force both direct and indirect rendering.");
|
||||
__glutTryDirect = GL_FALSE;
|
||||
removeArgs(argcp, &argv[1], 1);
|
||||
} else if (!strcmp(__glutArgv[i], "-iconic")) {
|
||||
__glutIconic = GL_TRUE;
|
||||
removeArgs(argcp, &argv[1], 1);
|
||||
} else if (!strcmp(__glutArgv[i], "-gldebug")) {
|
||||
__glutDebug = GL_TRUE;
|
||||
removeArgs(argcp, &argv[1], 1);
|
||||
} else if (!strcmp(__glutArgv[i], "-sync")) {
|
||||
#if defined(_WIN32)
|
||||
__glutWarning("-sync option not supported by Win32 GLUT.");
|
||||
#endif
|
||||
synchronize = GL_TRUE;
|
||||
removeArgs(argcp, &argv[1], 1);
|
||||
} else {
|
||||
/* Once unknown option encountered, stop command line
|
||||
processing. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
#if defined(__OS2__)
|
||||
__glutOpenOS2Connection(display);
|
||||
#elif defined(_WIN32)
|
||||
__glutOpenWin32Connection(display);
|
||||
#else
|
||||
__glutOpenXConnection(display);
|
||||
#endif
|
||||
if (geometry) {
|
||||
int flags, x, y, width, height;
|
||||
|
||||
/* Fix bogus "{width|height} may be used before set"
|
||||
warning */
|
||||
width = 0;
|
||||
height = 0;
|
||||
|
||||
flags = XParseGeometry(geometry, &x, &y,
|
||||
(unsigned int *) &width, (unsigned int *) &height);
|
||||
if (WidthValue & flags) {
|
||||
/* Careful because X does not allow zero or negative
|
||||
width windows */
|
||||
if (width > 0)
|
||||
__glutInitWidth = width;
|
||||
}
|
||||
if (HeightValue & flags) {
|
||||
/* Careful because X does not allow zero or negative
|
||||
height windows */
|
||||
if (height > 0)
|
||||
__glutInitHeight = height;
|
||||
}
|
||||
glutInitWindowSize(__glutInitWidth, __glutInitHeight);
|
||||
if (XValue & flags) {
|
||||
if (XNegative & flags)
|
||||
x = DisplayWidth(__glutDisplay, __glutScreen) +
|
||||
x - __glutSizeHints.width;
|
||||
/* Play safe: reject negative X locations */
|
||||
if (x >= 0)
|
||||
__glutInitX = x;
|
||||
}
|
||||
if (YValue & flags) {
|
||||
if (YNegative & flags)
|
||||
y = DisplayHeight(__glutDisplay, __glutScreen) +
|
||||
y - __glutSizeHints.height;
|
||||
/* Play safe: reject negative Y locations */
|
||||
if (y >= 0)
|
||||
__glutInitY = y;
|
||||
}
|
||||
glutInitWindowPosition(__glutInitX, __glutInitY);
|
||||
}
|
||||
__glutInitTime(&unused);
|
||||
|
||||
/* check if GLUT_FPS env var is set */
|
||||
{
|
||||
const char *fps = getenv("GLUT_FPS");
|
||||
if (fps) {
|
||||
sscanf(fps, "%d", &__glutFPS);
|
||||
if (__glutFPS <= 0)
|
||||
__glutFPS = 5000; /* 5000 milliseconds */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
void APIENTRY
|
||||
__glutInitWithExit(int *argcp, char **argv, void (__cdecl *exitfunc)(int))
|
||||
{
|
||||
__glutExitFunc = exitfunc;
|
||||
glutInit(argcp, argv);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY
|
||||
glutInitWindowPosition(int x, int y)
|
||||
{
|
||||
__glutInitX = x;
|
||||
__glutInitY = y;
|
||||
if (x >= 0 && y >= 0) {
|
||||
__glutSizeHints.x = x;
|
||||
__glutSizeHints.y = y;
|
||||
__glutSizeHints.flags |= USPosition;
|
||||
} else {
|
||||
__glutSizeHints.flags &= ~USPosition;
|
||||
}
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutInitWindowSize(int width, int height)
|
||||
{
|
||||
__glutInitWidth = width;
|
||||
__glutInitHeight = height;
|
||||
if (width > 0 && height > 0) {
|
||||
__glutSizeHints.width = width;
|
||||
__glutSizeHints.height = height;
|
||||
__glutSizeHints.flags |= USSize;
|
||||
} else {
|
||||
__glutSizeHints.flags &= ~USSize;
|
||||
}
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutInitDisplayMode(unsigned int mask)
|
||||
{
|
||||
__glutDisplayMode = mask;
|
||||
}
|
||||
|
||||
/* ENDCENTRY */
|
|
@ -0,0 +1,628 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1994, 1997, 1998. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "glutint.h"
|
||||
#define POFIG 0
|
||||
#if POFIG
|
||||
|
||||
int __glutNumDials = 0;
|
||||
int __glutNumSpaceballButtons = 0;
|
||||
int __glutNumButtonBoxButtons = 0;
|
||||
int __glutNumTabletButtons = 0;
|
||||
int __glutNumMouseButtons = 3; /* Good guess. */
|
||||
XDevice *__glutTablet = NULL;
|
||||
XDevice *__glutDials = NULL;
|
||||
XDevice *__glutSpaceball = NULL;
|
||||
|
||||
int __glutHasJoystick = 0;
|
||||
int __glutNumJoystickButtons = 0;
|
||||
int __glutNumJoystickAxes = 0;
|
||||
|
||||
#if !defined(_WIN32)
|
||||
typedef struct _Range {
|
||||
int min;
|
||||
int range;
|
||||
} Range;
|
||||
|
||||
#define NUM_SPACEBALL_AXIS 6
|
||||
#define NUM_TABLET_AXIS 2
|
||||
#define NUM_DIALS_AXIS 8
|
||||
|
||||
Range __glutSpaceballRange[NUM_SPACEBALL_AXIS];
|
||||
Range __glutTabletRange[NUM_TABLET_AXIS];
|
||||
int *__glutDialsResolution;
|
||||
|
||||
/* Safely assumes 0 is an illegal event type for X Input
|
||||
extension events. */
|
||||
int __glutDeviceMotionNotify = 0;
|
||||
int __glutDeviceButtonPress = 0;
|
||||
int __glutDeviceButtonPressGrab = 0;
|
||||
int __glutDeviceButtonRelease = 0;
|
||||
int __glutDeviceStateNotify = 0;
|
||||
|
||||
static int
|
||||
normalizeTabletPos(int axis, int rawValue)
|
||||
{
|
||||
assert(rawValue >= __glutTabletRange[axis].min);
|
||||
assert(rawValue <= __glutTabletRange[axis].min
|
||||
+ __glutTabletRange[axis].range);
|
||||
/* Normalize rawValue to between 0 and 4000. */
|
||||
return ((rawValue - __glutTabletRange[axis].min) * 4000) /
|
||||
__glutTabletRange[axis].range;
|
||||
}
|
||||
|
||||
static int
|
||||
normalizeDialAngle(int axis, int rawValue)
|
||||
{
|
||||
/* XXX Assumption made that the resolution of the device is
|
||||
number of clicks for one complete dial revolution. This
|
||||
is true for SGI's dial & button box. */
|
||||
return (rawValue * 360.0) / __glutDialsResolution[axis];
|
||||
}
|
||||
|
||||
static int
|
||||
normalizeSpaceballAngle(int axis, int rawValue)
|
||||
{
|
||||
assert(rawValue >= __glutSpaceballRange[axis].min);
|
||||
assert(rawValue <= __glutSpaceballRange[axis].min +
|
||||
__glutSpaceballRange[axis].range);
|
||||
/* Normalize rawValue to between -1800 and 1800. */
|
||||
return ((rawValue - __glutSpaceballRange[axis].min) * 3600) /
|
||||
__glutSpaceballRange[axis].range - 1800;
|
||||
}
|
||||
|
||||
static int
|
||||
normalizeSpaceballDelta(int axis, int rawValue)
|
||||
{
|
||||
assert(rawValue >= __glutSpaceballRange[axis].min);
|
||||
assert(rawValue <= __glutSpaceballRange[axis].min +
|
||||
__glutSpaceballRange[axis].range);
|
||||
/* Normalize rawValue to between -1000 and 1000. */
|
||||
return ((rawValue - __glutSpaceballRange[axis].min) * 2000) /
|
||||
__glutSpaceballRange[axis].range - 1000;
|
||||
}
|
||||
|
||||
static void
|
||||
queryTabletPos(GLUTwindow * window)
|
||||
{
|
||||
XDeviceState *state;
|
||||
XInputClass *any;
|
||||
XValuatorState *v;
|
||||
int i;
|
||||
|
||||
state = XQueryDeviceState(__glutDisplay, __glutTablet);
|
||||
any = state->data;
|
||||
for (i = 0; i < state->num_classes; i++) {
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
switch (any->c_class) {
|
||||
#else
|
||||
switch (any->class) {
|
||||
#endif
|
||||
case ValuatorClass:
|
||||
v = (XValuatorState *) any;
|
||||
if (v->num_valuators < 2)
|
||||
goto end;
|
||||
if (window->tabletPos[0] == -1)
|
||||
window->tabletPos[0] = normalizeTabletPos(0, v->valuators[0]);
|
||||
if (window->tabletPos[1] == -1)
|
||||
window->tabletPos[1] = normalizeTabletPos(1, v->valuators[1]);
|
||||
}
|
||||
any = (XInputClass *) ((char *) any + any->length);
|
||||
}
|
||||
end:
|
||||
XFreeDeviceState(state);
|
||||
}
|
||||
|
||||
static void
|
||||
tabletPosChange(GLUTwindow * window, int first, int count, int *data)
|
||||
{
|
||||
int i, value, genEvent = 0;
|
||||
|
||||
for (i = first; i < first + count; i++) {
|
||||
switch (i) {
|
||||
case 0: /* X axis */
|
||||
case 1: /* Y axis */
|
||||
value = normalizeTabletPos(i, data[i - first]);
|
||||
if (value != window->tabletPos[i]) {
|
||||
window->tabletPos[i] = value;
|
||||
genEvent = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (window->tabletPos[0] == -1 || window->tabletPos[1] == -1)
|
||||
queryTabletPos(window);
|
||||
if (genEvent)
|
||||
window->tabletMotion(window->tabletPos[0], window->tabletPos[1]);
|
||||
}
|
||||
#endif /* !_WIN32 */
|
||||
|
||||
static int
|
||||
__glutProcessDeviceEvents(XEvent * event)
|
||||
{
|
||||
#if !defined(_WIN32)
|
||||
GLUTwindow *window;
|
||||
|
||||
/* XXX Ugly code fan out. */
|
||||
|
||||
/* Can't use switch/case since X Input event types are
|
||||
dynamic. */
|
||||
|
||||
if (__glutDeviceMotionNotify && event->type == __glutDeviceMotionNotify) {
|
||||
XDeviceMotionEvent *devmot = (XDeviceMotionEvent *) event;
|
||||
|
||||
window = __glutGetWindow(devmot->window);
|
||||
if (window) {
|
||||
if (__glutTablet
|
||||
&& devmot->deviceid == __glutTablet->device_id
|
||||
&& window->tabletMotion) {
|
||||
tabletPosChange(window, devmot->first_axis, devmot->axes_count,
|
||||
devmot->axis_data);
|
||||
} else if (__glutDials
|
||||
&& devmot->deviceid == __glutDials->device_id
|
||||
&& window->dials) {
|
||||
int i, first = devmot->first_axis, count = devmot->axes_count;
|
||||
|
||||
for (i = first; i < first + count; i++)
|
||||
window->dials(i + 1,
|
||||
normalizeDialAngle(i, devmot->axis_data[i - first]));
|
||||
} else if (__glutSpaceball
|
||||
&& devmot->deviceid == __glutSpaceball->device_id) {
|
||||
/* XXX Assume that space ball motion events come in as
|
||||
all the first 6 axes. Assume first 3 axes are XYZ
|
||||
translations; second 3 axes are XYZ rotations. */
|
||||
if (devmot->first_axis == 0 && devmot->axes_count == 6) {
|
||||
if (window->spaceMotion)
|
||||
window->spaceMotion(
|
||||
normalizeSpaceballDelta(0, devmot->axis_data[0]),
|
||||
normalizeSpaceballDelta(1, devmot->axis_data[1]),
|
||||
normalizeSpaceballDelta(2, devmot->axis_data[2]));
|
||||
if (window->spaceRotate)
|
||||
window->spaceRotate(
|
||||
normalizeSpaceballAngle(3, devmot->axis_data[3]),
|
||||
normalizeSpaceballAngle(4, devmot->axis_data[4]),
|
||||
normalizeSpaceballAngle(5, devmot->axis_data[5]));
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
} else if (__glutDeviceButtonPress
|
||||
&& event->type == __glutDeviceButtonPress) {
|
||||
XDeviceButtonEvent *devbtn = (XDeviceButtonEvent *) event;
|
||||
|
||||
window = __glutGetWindow(devbtn->window);
|
||||
if (window) {
|
||||
if (__glutTablet
|
||||
&& devbtn->deviceid == __glutTablet->device_id
|
||||
&& window->tabletButton
|
||||
&& devbtn->first_axis == 0
|
||||
&& devbtn->axes_count == 2) {
|
||||
tabletPosChange(window, devbtn->first_axis, devbtn->axes_count,
|
||||
devbtn->axis_data);
|
||||
window->tabletButton(devbtn->button, GLUT_DOWN,
|
||||
window->tabletPos[0], window->tabletPos[1]);
|
||||
} else if (__glutDials
|
||||
&& devbtn->deviceid == __glutDials->device_id
|
||||
&& window->buttonBox) {
|
||||
window->buttonBox(devbtn->button, GLUT_DOWN);
|
||||
} else if (__glutSpaceball
|
||||
&& devbtn->deviceid == __glutSpaceball->device_id
|
||||
&& window->spaceButton) {
|
||||
window->spaceButton(devbtn->button, GLUT_DOWN);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
} else if (__glutDeviceButtonRelease
|
||||
&& event->type == __glutDeviceButtonRelease) {
|
||||
XDeviceButtonEvent *devbtn = (XDeviceButtonEvent *) event;
|
||||
|
||||
window = __glutGetWindow(devbtn->window);
|
||||
if (window) {
|
||||
if (__glutTablet
|
||||
&& devbtn->deviceid == __glutTablet->device_id
|
||||
&& window->tabletButton
|
||||
&& devbtn->first_axis == 0
|
||||
&& devbtn->axes_count == 2) {
|
||||
tabletPosChange(window, devbtn->first_axis, devbtn->axes_count,
|
||||
devbtn->axis_data);
|
||||
window->tabletButton(devbtn->button, GLUT_UP,
|
||||
window->tabletPos[0], window->tabletPos[1]);
|
||||
} else if (__glutDials
|
||||
&& devbtn->deviceid == __glutDials->device_id
|
||||
&& window->buttonBox) {
|
||||
window->buttonBox(devbtn->button, GLUT_UP);
|
||||
} else if (__glutSpaceball
|
||||
&& devbtn->deviceid == __glutSpaceball->device_id
|
||||
&& window->spaceButton) {
|
||||
window->spaceButton(devbtn->button, GLUT_UP);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
JOYINFOEX info;
|
||||
JOYCAPS joyCaps;
|
||||
|
||||
memset(&info, 0, sizeof(JOYINFOEX));
|
||||
info.dwSize = sizeof(JOYINFOEX);
|
||||
info.dwFlags = JOY_RETURNALL;
|
||||
|
||||
if (joyGetPosEx(JOYSTICKID1,&info) != JOYERR_NOERROR) {
|
||||
__glutHasJoystick = 1;
|
||||
joyGetDevCaps(JOYSTICKID1, &joyCaps, sizeof(joyCaps));
|
||||
__glutNumJoystickButtons = joyCaps.wNumButtons;
|
||||
__glutNumJoystickAxes = joyCaps.wNumAxes;
|
||||
} else {
|
||||
__glutHasJoystick = 0;
|
||||
__glutNumJoystickButtons = 0;
|
||||
__glutNumJoystickAxes = 0;
|
||||
}
|
||||
}
|
||||
#endif /* !_WIN32 */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static GLUTeventParser eventParser =
|
||||
{__glutProcessDeviceEvents, NULL};
|
||||
|
||||
static void
|
||||
addDeviceEventParser(void)
|
||||
{
|
||||
static Bool been_here = False;
|
||||
|
||||
if (been_here)
|
||||
return;
|
||||
been_here = True;
|
||||
__glutRegisterEventParser(&eventParser);
|
||||
}
|
||||
|
||||
static int
|
||||
probeDevices(void)
|
||||
{
|
||||
static Bool been_here = False;
|
||||
static int support;
|
||||
#if !defined(_WIN32)
|
||||
XExtensionVersion *version;
|
||||
XDeviceInfoPtr device_info, device;
|
||||
XAnyClassPtr any;
|
||||
XButtonInfoPtr b;
|
||||
XValuatorInfoPtr v;
|
||||
XAxisInfoPtr a;
|
||||
int num_dev = 0, btns = 0, dials = 0;
|
||||
int i, j, k;
|
||||
#endif /* !_WIN32 */
|
||||
|
||||
if (been_here) {
|
||||
return support;
|
||||
}
|
||||
been_here = True;
|
||||
|
||||
#if !defined(_WIN32)
|
||||
version = XGetExtensionVersion(__glutDisplay, "XInputExtension");
|
||||
/* Ugh. XInput extension API forces annoying cast of a pointer
|
||||
to a long so it can be compared with the NoSuchExtension
|
||||
value (#defined to 1). */
|
||||
if (version == NULL || ((long) version) == NoSuchExtension) {
|
||||
support = 0;
|
||||
return support;
|
||||
}
|
||||
XFree(version);
|
||||
device_info = XListInputDevices(__glutDisplay, &num_dev);
|
||||
if (device_info) {
|
||||
for (i = 0; i < num_dev; i++) {
|
||||
/* XXX These are SGI names for these devices;
|
||||
unfortunately, no good standard exists for standard
|
||||
types of X input extension devices. */
|
||||
|
||||
device = &device_info[i];
|
||||
any = (XAnyClassPtr) device->inputclassinfo;
|
||||
|
||||
if (!__glutSpaceball && !strcmp(device->name, "spaceball")) {
|
||||
v = NULL;
|
||||
b = NULL;
|
||||
for (j = 0; j < device->num_classes; j++) {
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
switch (any->c_class) {
|
||||
#else
|
||||
switch (any->class) {
|
||||
#endif
|
||||
case ButtonClass:
|
||||
b = (XButtonInfoPtr) any;
|
||||
btns = b->num_buttons;
|
||||
break;
|
||||
case ValuatorClass:
|
||||
v = (XValuatorInfoPtr) any;
|
||||
/* Sanity check: at least 6 valuators? */
|
||||
if (v->num_axes < NUM_SPACEBALL_AXIS)
|
||||
goto skip_device;
|
||||
a = (XAxisInfoPtr) ((char *) v + sizeof(XValuatorInfo));
|
||||
for (k = 0; k < NUM_SPACEBALL_AXIS; k++, a++) {
|
||||
__glutSpaceballRange[k].min = a->min_value;
|
||||
__glutSpaceballRange[k].range = a->max_value - a->min_value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
any = (XAnyClassPtr) ((char *) any + any->length);
|
||||
}
|
||||
if (v) {
|
||||
__glutSpaceball = XOpenDevice(__glutDisplay, device->id);
|
||||
if (__glutSpaceball) {
|
||||
__glutNumSpaceballButtons = btns;
|
||||
addDeviceEventParser();
|
||||
}
|
||||
}
|
||||
} else if (!__glutDials && !strcmp(device->name, "dial+buttons")) {
|
||||
v = NULL;
|
||||
b = NULL;
|
||||
for (j = 0; j < device->num_classes; j++) {
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
switch (any->c_class) {
|
||||
#else
|
||||
switch (any->class) {
|
||||
#endif
|
||||
case ButtonClass:
|
||||
b = (XButtonInfoPtr) any;
|
||||
btns = b->num_buttons;
|
||||
break;
|
||||
case ValuatorClass:
|
||||
v = (XValuatorInfoPtr) any;
|
||||
/* Sanity check: at least 8 valuators? */
|
||||
if (v->num_axes < NUM_DIALS_AXIS)
|
||||
goto skip_device;
|
||||
dials = v->num_axes;
|
||||
__glutDialsResolution = (int *) malloc(sizeof(int) * dials);
|
||||
a = (XAxisInfoPtr) ((char *) v + sizeof(XValuatorInfo));
|
||||
for (k = 0; k < dials; k++, a++) {
|
||||
__glutDialsResolution[k] = a->resolution;
|
||||
}
|
||||
break;
|
||||
}
|
||||
any = (XAnyClassPtr) ((char *) any + any->length);
|
||||
}
|
||||
if (v) {
|
||||
__glutDials = XOpenDevice(__glutDisplay, device->id);
|
||||
if (__glutDials) {
|
||||
__glutNumButtonBoxButtons = btns;
|
||||
__glutNumDials = dials;
|
||||
addDeviceEventParser();
|
||||
}
|
||||
}
|
||||
} else if (!__glutTablet && !strcmp(device->name, "tablet")) {
|
||||
v = NULL;
|
||||
b = NULL;
|
||||
for (j = 0; j < device->num_classes; j++) {
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
switch (any->c_class) {
|
||||
#else
|
||||
switch (any->class) {
|
||||
#endif
|
||||
case ButtonClass:
|
||||
b = (XButtonInfoPtr) any;
|
||||
btns = b->num_buttons;
|
||||
break;
|
||||
case ValuatorClass:
|
||||
v = (XValuatorInfoPtr) any;
|
||||
/* Sanity check: exactly 2 valuators? */
|
||||
if (v->num_axes != NUM_TABLET_AXIS)
|
||||
goto skip_device;
|
||||
a = (XAxisInfoPtr) ((char *) v + sizeof(XValuatorInfo));
|
||||
for (k = 0; k < NUM_TABLET_AXIS; k++, a++) {
|
||||
__glutTabletRange[k].min = a->min_value;
|
||||
__glutTabletRange[k].range = a->max_value - a->min_value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
any = (XAnyClassPtr) ((char *) any + any->length);
|
||||
}
|
||||
if (v) {
|
||||
__glutTablet = XOpenDevice(__glutDisplay, device->id);
|
||||
if (__glutTablet) {
|
||||
__glutNumTabletButtons = btns;
|
||||
addDeviceEventParser();
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(device->name, "mouse")) {
|
||||
for (j = 0; j < device->num_classes; j++) {
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
if (any->c_class == ButtonClass) {
|
||||
#else
|
||||
if (any->class == ButtonClass) {
|
||||
#endif
|
||||
b = (XButtonInfoPtr) any;
|
||||
__glutNumMouseButtons = b->num_buttons;
|
||||
}
|
||||
any = (XAnyClassPtr) ((char *) any + any->length);
|
||||
}
|
||||
}
|
||||
skip_device:;
|
||||
}
|
||||
XFreeDeviceList(device_info);
|
||||
}
|
||||
#else /* _WIN32 */
|
||||
__glutNumMouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
|
||||
#endif /* !_WIN32 */
|
||||
/* X Input extension might be supported, but only if there is
|
||||
a tablet, dials, or spaceball do we claim devices are
|
||||
supported. */
|
||||
support = __glutTablet || __glutDials || __glutSpaceball;
|
||||
return support;
|
||||
}
|
||||
|
||||
void
|
||||
__glutUpdateInputDeviceMask(GLUTwindow * window)
|
||||
{
|
||||
#if !defined(_WIN32)
|
||||
/* 5 (dial and buttons) + 5 (tablet locator and buttons) + 5
|
||||
(Spaceball buttons and axis) = 15 */
|
||||
XEventClass eventList[15];
|
||||
int rc, numEvents;
|
||||
|
||||
rc = probeDevices();
|
||||
if (rc) {
|
||||
numEvents = 0;
|
||||
if (__glutTablet) {
|
||||
if (window->tabletMotion) {
|
||||
DeviceMotionNotify(__glutTablet, __glutDeviceMotionNotify,
|
||||
eventList[numEvents]);
|
||||
numEvents++;
|
||||
}
|
||||
if (window->tabletButton) {
|
||||
DeviceButtonPress(__glutTablet, __glutDeviceButtonPress,
|
||||
eventList[numEvents]);
|
||||
numEvents++;
|
||||
DeviceButtonPressGrab(__glutTablet, __glutDeviceButtonPressGrab,
|
||||
eventList[numEvents]);
|
||||
numEvents++;
|
||||
DeviceButtonRelease(__glutTablet, __glutDeviceButtonRelease,
|
||||
eventList[numEvents]);
|
||||
numEvents++;
|
||||
}
|
||||
if (window->tabletMotion || window->tabletButton) {
|
||||
DeviceStateNotify(__glutTablet, __glutDeviceStateNotify,
|
||||
eventList[numEvents]);
|
||||
numEvents++;
|
||||
}
|
||||
}
|
||||
if (__glutDials) {
|
||||
if (window->dials) {
|
||||
DeviceMotionNotify(__glutDials, __glutDeviceMotionNotify,
|
||||
eventList[numEvents]);
|
||||
numEvents++;
|
||||
}
|
||||
if (window->buttonBox) {
|
||||
DeviceButtonPress(__glutDials, __glutDeviceButtonPress,
|
||||
eventList[numEvents]);
|
||||
numEvents++;
|
||||
DeviceButtonPressGrab(__glutDials, __glutDeviceButtonPressGrab,
|
||||
eventList[numEvents]);
|
||||
numEvents++;
|
||||
DeviceButtonRelease(__glutDials, __glutDeviceButtonRelease,
|
||||
eventList[numEvents]);
|
||||
numEvents++;
|
||||
}
|
||||
if (window->dials || window->buttonBox) {
|
||||
DeviceStateNotify(__glutDials, __glutDeviceStateNotify,
|
||||
eventList[numEvents]);
|
||||
numEvents++;
|
||||
}
|
||||
}
|
||||
if (__glutSpaceball) {
|
||||
if (window->spaceMotion || window->spaceRotate) {
|
||||
DeviceMotionNotify(__glutSpaceball, __glutDeviceMotionNotify,
|
||||
eventList[numEvents]);
|
||||
numEvents++;
|
||||
}
|
||||
if (window->spaceButton) {
|
||||
DeviceButtonPress(__glutSpaceball, __glutDeviceButtonPress,
|
||||
eventList[numEvents]);
|
||||
numEvents++;
|
||||
DeviceButtonPressGrab(__glutSpaceball, __glutDeviceButtonPressGrab,
|
||||
eventList[numEvents]);
|
||||
numEvents++;
|
||||
DeviceButtonRelease(__glutSpaceball, __glutDeviceButtonRelease,
|
||||
eventList[numEvents]);
|
||||
numEvents++;
|
||||
}
|
||||
if (window->spaceMotion || window->spaceRotate || window->spaceButton) {
|
||||
DeviceStateNotify(__glutSpaceball, __glutDeviceStateNotify,
|
||||
eventList[numEvents]);
|
||||
numEvents++;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
if (window->children) {
|
||||
GLUTwindow *child = window->children;
|
||||
|
||||
do {
|
||||
XChangeDeviceDontPropagateList(__glutDisplay, child->win,
|
||||
numEvents, eventList, AddToList);
|
||||
child = child->siblings;
|
||||
} while (child);
|
||||
}
|
||||
#endif
|
||||
XSelectExtensionEvent(__glutDisplay, window->win,
|
||||
eventList, numEvents);
|
||||
if (window->overlay) {
|
||||
XSelectExtensionEvent(__glutDisplay, window->overlay->win,
|
||||
eventList, numEvents);
|
||||
}
|
||||
} else {
|
||||
/* X Input extension not supported; no chance for exotic
|
||||
input devices. */
|
||||
}
|
||||
#endif /* !_WIN32 */
|
||||
}
|
||||
|
||||
#endif //POFIG
|
||||
|
||||
/* CENTRY */
|
||||
int GLUTAPIENTRY
|
||||
glutDeviceGet(GLenum param)
|
||||
{
|
||||
#if POFIG
|
||||
probeDevices();
|
||||
#endif
|
||||
switch (param) {
|
||||
case GLUT_HAS_KEYBOARD:
|
||||
case GLUT_HAS_MOUSE:
|
||||
/* Assume window system always has mouse and keyboard. */
|
||||
return 1;
|
||||
#if POFIG
|
||||
case GLUT_HAS_SPACEBALL:
|
||||
return __glutSpaceball != NULL;
|
||||
case GLUT_HAS_DIAL_AND_BUTTON_BOX:
|
||||
return __glutDials != NULL;
|
||||
case GLUT_HAS_TABLET:
|
||||
return __glutTablet != NULL;
|
||||
case GLUT_NUM_MOUSE_BUTTONS:
|
||||
return __glutNumMouseButtons;
|
||||
case GLUT_NUM_SPACEBALL_BUTTONS:
|
||||
return __glutNumSpaceballButtons;
|
||||
case GLUT_NUM_BUTTON_BOX_BUTTONS:
|
||||
return __glutNumButtonBoxButtons;
|
||||
case GLUT_NUM_DIALS:
|
||||
return __glutNumDials;
|
||||
case GLUT_NUM_TABLET_BUTTONS:
|
||||
return __glutNumTabletButtons;
|
||||
case GLUT_DEVICE_IGNORE_KEY_REPEAT:
|
||||
return __glutCurrentWindow->ignoreKeyRepeat;
|
||||
#ifndef _WIN32
|
||||
case GLUT_DEVICE_KEY_REPEAT:
|
||||
{
|
||||
XKeyboardState state;
|
||||
|
||||
XGetKeyboardControl(__glutDisplay, &state);
|
||||
return state.global_auto_repeat;
|
||||
}
|
||||
case GLUT_JOYSTICK_POLL_RATE:
|
||||
return 0;
|
||||
#else
|
||||
case GLUT_DEVICE_KEY_REPEAT:
|
||||
/* Win32 cannot globally disable key repeat. */
|
||||
return GLUT_KEY_REPEAT_ON;
|
||||
case GLUT_JOYSTICK_POLL_RATE:
|
||||
return __glutCurrentWindow->joyPollInterval;
|
||||
#endif
|
||||
case GLUT_HAS_JOYSTICK:
|
||||
return __glutHasJoystick;
|
||||
case GLUT_JOYSTICK_BUTTONS:
|
||||
return __glutNumJoystickButtons;
|
||||
case GLUT_JOYSTICK_AXES:
|
||||
return __glutNumJoystickAxes;
|
||||
#endif //POFIG
|
||||
default:
|
||||
__glutWarning("invalid glutDeviceGet parameter: %d", param);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/* ENDCENTRY */
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1997. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "glutint.h"
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY
|
||||
glutKeyboardFunc(GLUTkeyboardCB keyboardFunc)
|
||||
{
|
||||
__glutChangeWindowEventMask(KeyPressMask,
|
||||
keyboardFunc != NULL || __glutCurrentWindow->special != NULL);
|
||||
__glutCurrentWindow->keyboard = keyboardFunc;
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutSpecialFunc(GLUTspecialCB specialFunc)
|
||||
{
|
||||
__glutChangeWindowEventMask(KeyPressMask,
|
||||
specialFunc != NULL || __glutCurrentWindow->keyboard != NULL);
|
||||
__glutCurrentWindow->special = specialFunc;
|
||||
}
|
||||
|
||||
/* ENDCENTRY */
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1996, 1997. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#include "glutint.h"
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY
|
||||
glutIgnoreKeyRepeat(int ignore)
|
||||
{
|
||||
__glutCurrentWindow->ignoreKeyRepeat = ignore;
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutSetKeyRepeat(int repeatMode)
|
||||
{
|
||||
#if !defined(_WIN32) && !defined(__OS2PM__)
|
||||
XKeyboardControl values;
|
||||
|
||||
/* GLUT's repeatMode #define's match the Xlib API values. */
|
||||
values.auto_repeat_mode = repeatMode;
|
||||
XChangeKeyboardControl(__glutDisplay, KBAutoRepeatMode, &values);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ENDCENTRY */
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1997. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "glutint.h"
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY
|
||||
glutKeyboardUpFunc(GLUTkeyboardCB keyboardUpFunc)
|
||||
{
|
||||
__glutChangeWindowEventMask(KeyReleaseMask,
|
||||
keyboardUpFunc != NULL || __glutCurrentWindow->specialUp != NULL);
|
||||
__glutCurrentWindow->keyboardUp = keyboardUpFunc;
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutSpecialUpFunc(GLUTspecialCB specialUpFunc)
|
||||
{
|
||||
__glutChangeWindowEventMask(KeyReleaseMask,
|
||||
specialUpFunc != NULL || __glutCurrentWindow->keyboardUp != NULL);
|
||||
__glutCurrentWindow->specialUp = specialUpFunc;
|
||||
}
|
||||
|
||||
/* ENDCENTRY */
|
|
@ -0,0 +1,57 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1996. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "glutint.h"
|
||||
|
||||
int __glutMesaSwapHackSupport = 0; /* Not supported until
|
||||
proven otherwise. */
|
||||
|
||||
/* Use the "Mesa swap hack" if reasonable if and only if
|
||||
MESA_SWAP_HACK is set to something whose first character is
|
||||
not "N" or "n" AND "Brian Paul" is the vendor string AND
|
||||
"Mesa X11"* (or "Mesa" for backward compatibility) is the
|
||||
renderer string.
|
||||
|
||||
Anyone who modifies Mesa so that glXSwapBuffers does not
|
||||
simply blit the previously rendered back buffer should
|
||||
change either their vendor or renderer string to avoid
|
||||
confusing GLUT. */
|
||||
|
||||
void
|
||||
__glutDetermineMesaSwapHackSupport(void)
|
||||
{
|
||||
static int doneAlready = 0;
|
||||
char *env, *vendor, *renderer;
|
||||
|
||||
if (doneAlready)
|
||||
return;
|
||||
env = getenv("MESA_SWAP_HACK");
|
||||
if (env) {
|
||||
if ((env[0] != 'n') && (env[0] != 'N')) {
|
||||
vendor = (char *) glGetString(GL_VENDOR);
|
||||
renderer = (char *) glGetString(GL_RENDERER);
|
||||
|
||||
/* Old versions of X11 Mesa uses the renderer string
|
||||
"Mesa"; Brian plans to start using "Mesa X11" to
|
||||
distinguish the X version of Mesa from other flavor
|
||||
such as Windows or 3Dfx. */
|
||||
|
||||
#define MESA_X11 "Mesa X11"
|
||||
|
||||
/* XXX At some point in the future, eliminate the
|
||||
backward compatibility for the old "Mesa" renderer
|
||||
string. */
|
||||
|
||||
if (!strcmp(vendor, "Brian Paul") && (!strcmp(renderer, "Mesa") ||
|
||||
!strncmp(renderer, MESA_X11, sizeof(MESA_X11) - 1)))
|
||||
__glutMesaSwapHackSupport = 1;
|
||||
}
|
||||
}
|
||||
doneAlready = 1;
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1994. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#include "glutint.h"
|
||||
|
||||
/* CENTRY */
|
||||
int GLUTAPIENTRY
|
||||
glutGetModifiers(void)
|
||||
{
|
||||
int modifiers;
|
||||
|
||||
if(__glutModifierMask == (unsigned int) ~0) {
|
||||
__glutWarning(
|
||||
"glutCurrentModifiers: do not call outside core input callback.");
|
||||
return 0;
|
||||
}
|
||||
modifiers = 0;
|
||||
if(__glutModifierMask & (ShiftMask|LockMask))
|
||||
modifiers |= GLUT_ACTIVE_SHIFT;
|
||||
if(__glutModifierMask & ControlMask)
|
||||
modifiers |= GLUT_ACTIVE_CTRL;
|
||||
if(__glutModifierMask & Mod1Mask)
|
||||
modifiers |= GLUT_ACTIVE_ALT;
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
/* ENDCENTRY */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,595 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1994, 1997. */
|
||||
|
||||
/**
|
||||
(c) Copyright 1993, Silicon Graphics, Inc.
|
||||
|
||||
ALL RIGHTS RESERVED
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
for any purpose and without fee is hereby granted, provided
|
||||
that the above copyright notice appear in all copies and that
|
||||
both the copyright notice and this permission notice appear in
|
||||
supporting documentation, and that the name of Silicon
|
||||
Graphics, Inc. not be used in advertising or publicity
|
||||
pertaining to distribution of the software without specific,
|
||||
written prior permission.
|
||||
|
||||
THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU
|
||||
"AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR
|
||||
OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
|
||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO
|
||||
EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE
|
||||
ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR
|
||||
CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,
|
||||
INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,
|
||||
SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR
|
||||
NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY
|
||||
OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
US Government Users Restricted Rights
|
||||
|
||||
Use, duplication, or disclosure by the Government is subject to
|
||||
restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
||||
(c)(1)(ii) of the Rights in Technical Data and Computer
|
||||
Software clause at DFARS 252.227-7013 and/or in similar or
|
||||
successor clauses in the FAR or the DOD or NASA FAR
|
||||
Supplement. Unpublished-- rights reserved under the copyright
|
||||
laws of the United States. Contractor/manufacturer is Silicon
|
||||
Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA
|
||||
94039-7311.
|
||||
|
||||
OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include "glutint.h"
|
||||
|
||||
/* Some <math.h> files do not define M_PI... */
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
static GLUquadricObj *quadObj;
|
||||
|
||||
#define QUAD_OBJ_INIT() { if(!quadObj) initQuadObj(); }
|
||||
|
||||
static void
|
||||
initQuadObj(void)
|
||||
{
|
||||
quadObj = gluNewQuadric();
|
||||
if (!quadObj)
|
||||
__glutFatalError("out of memory.");
|
||||
}
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY
|
||||
glutWireSphere(GLdouble radius, GLint slices, GLint stacks)
|
||||
{
|
||||
QUAD_OBJ_INIT();
|
||||
gluQuadricDrawStyle(quadObj, GLU_LINE);
|
||||
gluQuadricNormals(quadObj, GLU_SMOOTH);
|
||||
/* If we ever changed/used the texture or orientation state
|
||||
of quadObj, we'd need to change it to the defaults here
|
||||
with gluQuadricTexture and/or gluQuadricOrientation. */
|
||||
gluSphere(quadObj, radius, slices, stacks);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutSolidSphere(GLdouble radius, GLint slices, GLint stacks)
|
||||
{
|
||||
QUAD_OBJ_INIT();
|
||||
gluQuadricDrawStyle(quadObj, GLU_FILL);
|
||||
gluQuadricNormals(quadObj, GLU_SMOOTH);
|
||||
/* If we ever changed/used the texture or orientation state
|
||||
of quadObj, we'd need to change it to the defaults here
|
||||
with gluQuadricTexture and/or gluQuadricOrientation. */
|
||||
gluSphere(quadObj, radius, slices, stacks);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutWireCone(GLdouble base, GLdouble height,
|
||||
GLint slices, GLint stacks)
|
||||
{
|
||||
QUAD_OBJ_INIT();
|
||||
gluQuadricDrawStyle(quadObj, GLU_LINE);
|
||||
gluQuadricNormals(quadObj, GLU_SMOOTH);
|
||||
/* If we ever changed/used the texture or orientation state
|
||||
of quadObj, we'd need to change it to the defaults here
|
||||
with gluQuadricTexture and/or gluQuadricOrientation. */
|
||||
gluCylinder(quadObj, base, 0.0, height, slices, stacks);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutSolidCone(GLdouble base, GLdouble height,
|
||||
GLint slices, GLint stacks)
|
||||
{
|
||||
QUAD_OBJ_INIT();
|
||||
gluQuadricDrawStyle(quadObj, GLU_FILL);
|
||||
gluQuadricNormals(quadObj, GLU_SMOOTH);
|
||||
/* If we ever changed/used the texture or orientation state
|
||||
of quadObj, we'd need to change it to the defaults here
|
||||
with gluQuadricTexture and/or gluQuadricOrientation. */
|
||||
gluCylinder(quadObj, base, 0.0, height, slices, stacks);
|
||||
}
|
||||
|
||||
/* ENDCENTRY */
|
||||
|
||||
static void
|
||||
drawBox(GLfloat size, GLenum type)
|
||||
{
|
||||
static GLfloat n[6][3] =
|
||||
{
|
||||
{-1.0, 0.0, 0.0},
|
||||
{0.0, 1.0, 0.0},
|
||||
{1.0, 0.0, 0.0},
|
||||
{0.0, -1.0, 0.0},
|
||||
{0.0, 0.0, 1.0},
|
||||
{0.0, 0.0, -1.0}
|
||||
};
|
||||
static GLint faces[6][4] =
|
||||
{
|
||||
{0, 1, 2, 3},
|
||||
{3, 2, 6, 7},
|
||||
{7, 6, 5, 4},
|
||||
{4, 5, 1, 0},
|
||||
{5, 6, 2, 1},
|
||||
{7, 4, 0, 3}
|
||||
};
|
||||
GLfloat v[8][3];
|
||||
GLint i;
|
||||
|
||||
v[0][0] = v[1][0] = v[2][0] = v[3][0] = -size / 2;
|
||||
v[4][0] = v[5][0] = v[6][0] = v[7][0] = size / 2;
|
||||
v[0][1] = v[1][1] = v[4][1] = v[5][1] = -size / 2;
|
||||
v[2][1] = v[3][1] = v[6][1] = v[7][1] = size / 2;
|
||||
v[0][2] = v[3][2] = v[4][2] = v[7][2] = -size / 2;
|
||||
v[1][2] = v[2][2] = v[5][2] = v[6][2] = size / 2;
|
||||
|
||||
for (i = 5; i >= 0; i--) {
|
||||
glBegin(type);
|
||||
glNormal3fv(&n[i][0]);
|
||||
glVertex3fv(&v[faces[i][0]][0]);
|
||||
glVertex3fv(&v[faces[i][1]][0]);
|
||||
glVertex3fv(&v[faces[i][2]][0]);
|
||||
glVertex3fv(&v[faces[i][3]][0]);
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY
|
||||
glutWireCube(GLdouble size)
|
||||
{
|
||||
drawBox(size, GL_LINE_LOOP);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutSolidCube(GLdouble size)
|
||||
{
|
||||
drawBox(size, GL_QUADS);
|
||||
}
|
||||
|
||||
/* ENDCENTRY */
|
||||
|
||||
static void
|
||||
doughnut(GLfloat r, GLfloat R, GLint nsides, GLint rings)
|
||||
{
|
||||
int i, j;
|
||||
GLfloat theta, phi, theta1;
|
||||
GLfloat cosTheta, sinTheta;
|
||||
GLfloat cosTheta1, sinTheta1;
|
||||
GLfloat ringDelta, sideDelta;
|
||||
|
||||
ringDelta = 2.0 * M_PI / rings;
|
||||
sideDelta = 2.0 * M_PI / nsides;
|
||||
|
||||
theta = 0.0;
|
||||
cosTheta = 1.0;
|
||||
sinTheta = 0.0;
|
||||
for (i = rings - 1; i >= 0; i--) {
|
||||
theta1 = theta + ringDelta;
|
||||
cosTheta1 = cos(theta1);
|
||||
sinTheta1 = sin(theta1);
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
phi = 0.0;
|
||||
for (j = nsides; j >= 0; j--) {
|
||||
GLfloat cosPhi, sinPhi, dist;
|
||||
|
||||
phi += sideDelta;
|
||||
cosPhi = cos(phi);
|
||||
sinPhi = sin(phi);
|
||||
dist = R + r * cosPhi;
|
||||
|
||||
glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
|
||||
glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
|
||||
glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
|
||||
glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi);
|
||||
}
|
||||
glEnd();
|
||||
theta = theta1;
|
||||
cosTheta = cosTheta1;
|
||||
sinTheta = sinTheta1;
|
||||
}
|
||||
}
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY
|
||||
glutWireTorus(GLdouble innerRadius, GLdouble outerRadius,
|
||||
GLint nsides, GLint rings)
|
||||
{
|
||||
glPushAttrib(GL_POLYGON_BIT);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
doughnut(innerRadius, outerRadius, nsides, rings);
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius,
|
||||
GLint nsides, GLint rings)
|
||||
{
|
||||
doughnut(innerRadius, outerRadius, nsides, rings);
|
||||
}
|
||||
|
||||
/* ENDCENTRY */
|
||||
|
||||
static GLfloat dodec[20][3];
|
||||
|
||||
static void
|
||||
initDodecahedron(void)
|
||||
{
|
||||
GLfloat alpha, beta;
|
||||
|
||||
alpha = sqrt(2.0 / (3.0 + sqrt(5.0)));
|
||||
beta = 1.0 + sqrt(6.0 / (3.0 + sqrt(5.0)) -
|
||||
2.0 + 2.0 * sqrt(2.0 / (3.0 + sqrt(5.0))));
|
||||
/* *INDENT-OFF* */
|
||||
dodec[0][0] = -alpha; dodec[0][1] = 0; dodec[0][2] = beta;
|
||||
dodec[1][0] = alpha; dodec[1][1] = 0; dodec[1][2] = beta;
|
||||
dodec[2][0] = -1; dodec[2][1] = -1; dodec[2][2] = -1;
|
||||
dodec[3][0] = -1; dodec[3][1] = -1; dodec[3][2] = 1;
|
||||
dodec[4][0] = -1; dodec[4][1] = 1; dodec[4][2] = -1;
|
||||
dodec[5][0] = -1; dodec[5][1] = 1; dodec[5][2] = 1;
|
||||
dodec[6][0] = 1; dodec[6][1] = -1; dodec[6][2] = -1;
|
||||
dodec[7][0] = 1; dodec[7][1] = -1; dodec[7][2] = 1;
|
||||
dodec[8][0] = 1; dodec[8][1] = 1; dodec[8][2] = -1;
|
||||
dodec[9][0] = 1; dodec[9][1] = 1; dodec[9][2] = 1;
|
||||
dodec[10][0] = beta; dodec[10][1] = alpha; dodec[10][2] = 0;
|
||||
dodec[11][0] = beta; dodec[11][1] = -alpha; dodec[11][2] = 0;
|
||||
dodec[12][0] = -beta; dodec[12][1] = alpha; dodec[12][2] = 0;
|
||||
dodec[13][0] = -beta; dodec[13][1] = -alpha; dodec[13][2] = 0;
|
||||
dodec[14][0] = -alpha; dodec[14][1] = 0; dodec[14][2] = -beta;
|
||||
dodec[15][0] = alpha; dodec[15][1] = 0; dodec[15][2] = -beta;
|
||||
dodec[16][0] = 0; dodec[16][1] = beta; dodec[16][2] = alpha;
|
||||
dodec[17][0] = 0; dodec[17][1] = beta; dodec[17][2] = -alpha;
|
||||
dodec[18][0] = 0; dodec[18][1] = -beta; dodec[18][2] = alpha;
|
||||
dodec[19][0] = 0; dodec[19][1] = -beta; dodec[19][2] = -alpha;
|
||||
/* *INDENT-ON* */
|
||||
|
||||
}
|
||||
|
||||
#define DIFF3(_a,_b,_c) { \
|
||||
(_c)[0] = (_a)[0] - (_b)[0]; \
|
||||
(_c)[1] = (_a)[1] - (_b)[1]; \
|
||||
(_c)[2] = (_a)[2] - (_b)[2]; \
|
||||
}
|
||||
|
||||
static void
|
||||
crossprod(GLfloat v1[3], GLfloat v2[3], GLfloat prod[3])
|
||||
{
|
||||
GLfloat p[3]; /* in case prod == v1 or v2 */
|
||||
|
||||
p[0] = v1[1] * v2[2] - v2[1] * v1[2];
|
||||
p[1] = v1[2] * v2[0] - v2[2] * v1[0];
|
||||
p[2] = v1[0] * v2[1] - v2[0] * v1[1];
|
||||
prod[0] = p[0];
|
||||
prod[1] = p[1];
|
||||
prod[2] = p[2];
|
||||
}
|
||||
|
||||
static void
|
||||
normalize(GLfloat v[3])
|
||||
{
|
||||
GLfloat d;
|
||||
|
||||
d = sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
|
||||
if (d == 0.0) {
|
||||
__glutWarning("normalize: zero length vector");
|
||||
v[0] = d = 1.0;
|
||||
}
|
||||
d = 1 / d;
|
||||
v[0] *= d;
|
||||
v[1] *= d;
|
||||
v[2] *= d;
|
||||
}
|
||||
|
||||
static void
|
||||
pentagon(int a, int b, int c, int d, int e, GLenum shadeType)
|
||||
{
|
||||
GLfloat n0[3], d1[3], d2[3];
|
||||
|
||||
DIFF3(dodec[a], dodec[b], d1);
|
||||
DIFF3(dodec[b], dodec[c], d2);
|
||||
crossprod(d1, d2, n0);
|
||||
normalize(n0);
|
||||
|
||||
glBegin(shadeType);
|
||||
glNormal3fv(n0);
|
||||
glVertex3fv(&dodec[a][0]);
|
||||
glVertex3fv(&dodec[b][0]);
|
||||
glVertex3fv(&dodec[c][0]);
|
||||
glVertex3fv(&dodec[d][0]);
|
||||
glVertex3fv(&dodec[e][0]);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
static void
|
||||
dodecahedron(GLenum type)
|
||||
{
|
||||
static int inited = 0;
|
||||
|
||||
if (inited == 0) {
|
||||
inited = 1;
|
||||
initDodecahedron();
|
||||
}
|
||||
pentagon(0, 1, 9, 16, 5, type);
|
||||
pentagon(1, 0, 3, 18, 7, type);
|
||||
pentagon(1, 7, 11, 10, 9, type);
|
||||
pentagon(11, 7, 18, 19, 6, type);
|
||||
pentagon(8, 17, 16, 9, 10, type);
|
||||
pentagon(2, 14, 15, 6, 19, type);
|
||||
pentagon(2, 13, 12, 4, 14, type);
|
||||
pentagon(2, 19, 18, 3, 13, type);
|
||||
pentagon(3, 0, 5, 12, 13, type);
|
||||
pentagon(6, 15, 8, 10, 11, type);
|
||||
pentagon(4, 17, 8, 15, 14, type);
|
||||
pentagon(4, 12, 5, 16, 17, type);
|
||||
}
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY glutWireDodecahedron(void)
|
||||
{
|
||||
dodecahedron(GL_LINE_LOOP);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutSolidDodecahedron(void)
|
||||
{
|
||||
dodecahedron(GL_TRIANGLE_FAN);
|
||||
}
|
||||
|
||||
/* ENDCENTRY */
|
||||
|
||||
static void
|
||||
recorditem(GLfloat * n1, GLfloat * n2, GLfloat * n3,
|
||||
GLenum shadeType)
|
||||
{
|
||||
GLfloat q0[3], q1[3];
|
||||
|
||||
DIFF3(n1, n2, q0);
|
||||
DIFF3(n2, n3, q1);
|
||||
crossprod(q0, q1, q1);
|
||||
normalize(q1);
|
||||
|
||||
glBegin(shadeType);
|
||||
glNormal3fv(q1);
|
||||
glVertex3fv(n1);
|
||||
glVertex3fv(n2);
|
||||
glVertex3fv(n3);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
static void
|
||||
subdivide(GLfloat * v0, GLfloat * v1, GLfloat * v2,
|
||||
GLenum shadeType)
|
||||
{
|
||||
int depth;
|
||||
GLfloat w0[3], w1[3], w2[3];
|
||||
GLfloat l;
|
||||
int i, j, k, n;
|
||||
|
||||
depth = 1;
|
||||
for (i = 0; i < depth; i++) {
|
||||
for (j = 0; i + j < depth; j++) {
|
||||
k = depth - i - j;
|
||||
for (n = 0; n < 3; n++) {
|
||||
w0[n] = (i * v0[n] + j * v1[n] + k * v2[n]) / depth;
|
||||
w1[n] = ((i + 1) * v0[n] + j * v1[n] + (k - 1) * v2[n])
|
||||
/ depth;
|
||||
w2[n] = (i * v0[n] + (j + 1) * v1[n] + (k - 1) * v2[n])
|
||||
/ depth;
|
||||
}
|
||||
l = sqrt(w0[0] * w0[0] + w0[1] * w0[1] + w0[2] * w0[2]);
|
||||
w0[0] /= l;
|
||||
w0[1] /= l;
|
||||
w0[2] /= l;
|
||||
l = sqrt(w1[0] * w1[0] + w1[1] * w1[1] + w1[2] * w1[2]);
|
||||
w1[0] /= l;
|
||||
w1[1] /= l;
|
||||
w1[2] /= l;
|
||||
l = sqrt(w2[0] * w2[0] + w2[1] * w2[1] + w2[2] * w2[2]);
|
||||
w2[0] /= l;
|
||||
w2[1] /= l;
|
||||
w2[2] /= l;
|
||||
recorditem(w1, w0, w2, shadeType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
drawtriangle(int i, GLfloat data[][3], int ndx[][3],
|
||||
GLenum shadeType)
|
||||
{
|
||||
GLfloat *x0, *x1, *x2;
|
||||
|
||||
x0 = data[ndx[i][0]];
|
||||
x1 = data[ndx[i][1]];
|
||||
x2 = data[ndx[i][2]];
|
||||
subdivide(x0, x1, x2, shadeType);
|
||||
}
|
||||
|
||||
/* octahedron data: The octahedron produced is centered at the
|
||||
origin and has radius 1.0 */
|
||||
static GLfloat odata[6][3] =
|
||||
{
|
||||
{1.0, 0.0, 0.0},
|
||||
{-1.0, 0.0, 0.0},
|
||||
{0.0, 1.0, 0.0},
|
||||
{0.0, -1.0, 0.0},
|
||||
{0.0, 0.0, 1.0},
|
||||
{0.0, 0.0, -1.0}
|
||||
};
|
||||
|
||||
static int ondex[8][3] =
|
||||
{
|
||||
{0, 4, 2},
|
||||
{1, 2, 4},
|
||||
{0, 3, 4},
|
||||
{1, 4, 3},
|
||||
{0, 2, 5},
|
||||
{1, 5, 2},
|
||||
{0, 5, 3},
|
||||
{1, 3, 5}
|
||||
};
|
||||
|
||||
static void
|
||||
octahedron(GLenum shadeType)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 7; i >= 0; i--) {
|
||||
drawtriangle(i, odata, ondex, shadeType);
|
||||
}
|
||||
}
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY
|
||||
glutWireOctahedron(void)
|
||||
{
|
||||
octahedron(GL_LINE_LOOP);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutSolidOctahedron(void)
|
||||
{
|
||||
octahedron(GL_TRIANGLES);
|
||||
}
|
||||
|
||||
/* ENDCENTRY */
|
||||
|
||||
/* icosahedron data: These numbers are rigged to make an
|
||||
icosahedron of radius 1.0 */
|
||||
|
||||
#define X .525731112119133606
|
||||
#define Z .850650808352039932
|
||||
|
||||
static GLfloat idata[12][3] =
|
||||
{
|
||||
{-X, 0, Z},
|
||||
{X, 0, Z},
|
||||
{-X, 0, -Z},
|
||||
{X, 0, -Z},
|
||||
{0, Z, X},
|
||||
{0, Z, -X},
|
||||
{0, -Z, X},
|
||||
{0, -Z, -X},
|
||||
{Z, X, 0},
|
||||
{-Z, X, 0},
|
||||
{Z, -X, 0},
|
||||
{-Z, -X, 0}
|
||||
};
|
||||
|
||||
static int index[20][3] =
|
||||
{
|
||||
{0, 4, 1},
|
||||
{0, 9, 4},
|
||||
{9, 5, 4},
|
||||
{4, 5, 8},
|
||||
{4, 8, 1},
|
||||
{8, 10, 1},
|
||||
{8, 3, 10},
|
||||
{5, 3, 8},
|
||||
{5, 2, 3},
|
||||
{2, 7, 3},
|
||||
{7, 10, 3},
|
||||
{7, 6, 10},
|
||||
{7, 11, 6},
|
||||
{11, 0, 6},
|
||||
{0, 1, 6},
|
||||
{6, 1, 10},
|
||||
{9, 0, 11},
|
||||
{9, 11, 2},
|
||||
{9, 2, 5},
|
||||
{7, 2, 11},
|
||||
};
|
||||
|
||||
static void
|
||||
icosahedron(GLenum shadeType)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 19; i >= 0; i--) {
|
||||
drawtriangle(i, idata, index, shadeType);
|
||||
}
|
||||
}
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY
|
||||
glutWireIcosahedron(void)
|
||||
{
|
||||
icosahedron(GL_LINE_LOOP);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutSolidIcosahedron(void)
|
||||
{
|
||||
icosahedron(GL_TRIANGLES);
|
||||
}
|
||||
|
||||
/* ENDCENTRY */
|
||||
|
||||
/* tetrahedron data: */
|
||||
|
||||
#define T 1.73205080756887729
|
||||
|
||||
static GLfloat tdata[4][3] =
|
||||
{
|
||||
{T, T, T},
|
||||
{T, -T, -T},
|
||||
{-T, T, -T},
|
||||
{-T, -T, T}
|
||||
};
|
||||
|
||||
static int tndex[4][3] =
|
||||
{
|
||||
{0, 1, 3},
|
||||
{2, 1, 0},
|
||||
{3, 2, 0},
|
||||
{1, 2, 3}
|
||||
};
|
||||
|
||||
static void
|
||||
tetrahedron(GLenum shadeType)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 3; i >= 0; i--)
|
||||
drawtriangle(i, tdata, tndex, shadeType);
|
||||
}
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY
|
||||
glutWireTetrahedron(void)
|
||||
{
|
||||
tetrahedron(GL_LINE_LOOP);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutSolidTetrahedron(void)
|
||||
{
|
||||
tetrahedron(GL_TRIANGLES);
|
||||
}
|
||||
|
||||
/* ENDCENTRY */
|
|
@ -0,0 +1,42 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1994. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#include "glutint.h"
|
||||
#include "glutstroke.h"
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutStrokeCharacter(GLUTstrokeFont font, int c)
|
||||
{
|
||||
const StrokeCharRec *ch;
|
||||
const StrokeRec *stroke;
|
||||
const CoordRec *coord;
|
||||
StrokeFontPtr fontinfo;
|
||||
int i, j;
|
||||
|
||||
|
||||
#if defined(_WIN32)
|
||||
fontinfo = (StrokeFontPtr) __glutFont(font);
|
||||
#else
|
||||
fontinfo = (StrokeFontPtr) font;
|
||||
#endif
|
||||
|
||||
if (c < 0 || c >= fontinfo->num_chars)
|
||||
return;
|
||||
ch = &(fontinfo->ch[c]);
|
||||
if (ch) {
|
||||
for (i = ch->num_strokes, stroke = ch->stroke;
|
||||
i > 0; i--, stroke++) {
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (j = stroke->num_coords, coord = stroke->coord;
|
||||
j > 0; j--, coord++) {
|
||||
glVertex2f(coord->x, coord->y);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
glTranslatef(ch->right, 0.0, 0.0);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1994, 1997. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "glutint.h"
|
||||
|
||||
GLint __glutFPS = 0;
|
||||
GLint __glutSwapCount = 0;
|
||||
GLint __glutSwapTime = 0;
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY
|
||||
glutSwapBuffers(void)
|
||||
{
|
||||
GLUTwindow *window = __glutCurrentWindow;
|
||||
|
||||
if (window->renderWin == window->win) {
|
||||
if (__glutCurrentWindow->treatAsSingle) {
|
||||
/* Pretend the double buffered window is single buffered,
|
||||
so treat glutSwapBuffers as a no-op. */
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (__glutCurrentWindow->overlay->treatAsSingle) {
|
||||
/* Pretend the double buffered overlay is single
|
||||
buffered, so treat glutSwapBuffers as a no-op. */
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* For the MESA_SWAP_HACK. */
|
||||
window->usedSwapBuffers = 1;
|
||||
|
||||
SWAP_BUFFERS_LAYER(__glutCurrentWindow);
|
||||
|
||||
/* I considered putting the window being swapped on the
|
||||
GLUT_FINISH_WORK work list because you could call
|
||||
glutSwapBuffers from an idle callback which doesn't call
|
||||
__glutSetWindow which normally adds indirect rendering
|
||||
windows to the GLUT_FINISH_WORK work list. Not being put
|
||||
on the list could lead to the buffering up of multiple
|
||||
redisplays and buffer swaps and hamper interactivity. I
|
||||
consider this an application bug due to not using
|
||||
glutPostRedisplay to trigger redraws. If
|
||||
glutPostRedisplay were used, __glutSetWindow would be
|
||||
called and a glFinish to throttle buffering would occur. */
|
||||
|
||||
if (__glutFPS) {
|
||||
GLint t = glutGet(GLUT_ELAPSED_TIME);
|
||||
__glutSwapCount++;
|
||||
if (__glutSwapTime == 0)
|
||||
__glutSwapTime = t;
|
||||
else if (t - __glutSwapTime > __glutFPS) {
|
||||
float time = 0.001 * (t - __glutSwapTime);
|
||||
float fps = (float) __glutSwapCount / time;
|
||||
fprintf(stderr, "GLUT: %d frames in %.2f seconds = %.2f FPS\n",
|
||||
__glutSwapCount, time, fps);
|
||||
__glutSwapTime = t;
|
||||
__glutSwapCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* ENDCENTRY */
|
|
@ -0,0 +1,210 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1994. */
|
||||
|
||||
/**
|
||||
(c) Copyright 1993, Silicon Graphics, Inc.
|
||||
|
||||
ALL RIGHTS RESERVED
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
for any purpose and without fee is hereby granted, provided
|
||||
that the above copyright notice appear in all copies and that
|
||||
both the copyright notice and this permission notice appear in
|
||||
supporting documentation, and that the name of Silicon
|
||||
Graphics, Inc. not be used in advertising or publicity
|
||||
pertaining to distribution of the software without specific,
|
||||
written prior permission.
|
||||
|
||||
THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU
|
||||
"AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR
|
||||
OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
|
||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO
|
||||
EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE
|
||||
ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR
|
||||
CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,
|
||||
INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,
|
||||
SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR
|
||||
NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY
|
||||
OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
US Government Users Restricted Rights
|
||||
|
||||
Use, duplication, or disclosure by the Government is subject to
|
||||
restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
||||
(c)(1)(ii) of the Rights in Technical Data and Computer
|
||||
Software clause at DFARS 252.227-7013 and/or in similar or
|
||||
successor clauses in the FAR or the DOD or NASA FAR
|
||||
Supplement. Unpublished-- rights reserved under the copyright
|
||||
laws of the United States. Contractor/manufacturer is Silicon
|
||||
Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA
|
||||
94039-7311.
|
||||
|
||||
OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
#include "glutint.h"
|
||||
|
||||
/* Rim, body, lid, and bottom data must be reflected in x and
|
||||
y; handle and spout data across the y axis only. */
|
||||
|
||||
static int patchdata[][16] =
|
||||
{
|
||||
/* rim */
|
||||
{102, 103, 104, 105, 4, 5, 6, 7, 8, 9, 10, 11,
|
||||
12, 13, 14, 15},
|
||||
/* body */
|
||||
{12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
|
||||
24, 25, 26, 27},
|
||||
{24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36,
|
||||
37, 38, 39, 40},
|
||||
/* lid */
|
||||
{96, 96, 96, 96, 97, 98, 99, 100, 101, 101, 101,
|
||||
101, 0, 1, 2, 3,},
|
||||
{0, 1, 2, 3, 106, 107, 108, 109, 110, 111, 112,
|
||||
113, 114, 115, 116, 117},
|
||||
/* bottom */
|
||||
{118, 118, 118, 118, 124, 122, 119, 121, 123, 126,
|
||||
125, 120, 40, 39, 38, 37},
|
||||
/* handle */
|
||||
{41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
|
||||
53, 54, 55, 56},
|
||||
{53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
|
||||
28, 65, 66, 67},
|
||||
/* spout */
|
||||
{68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
|
||||
80, 81, 82, 83},
|
||||
{80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
|
||||
92, 93, 94, 95}
|
||||
};
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
static float cpdata[][3] =
|
||||
{
|
||||
{0.2, 0, 2.7}, {0.2, -0.112, 2.7}, {0.112, -0.2, 2.7}, {0,
|
||||
-0.2, 2.7}, {1.3375, 0, 2.53125}, {1.3375, -0.749, 2.53125},
|
||||
{0.749, -1.3375, 2.53125}, {0, -1.3375, 2.53125}, {1.4375,
|
||||
0, 2.53125}, {1.4375, -0.805, 2.53125}, {0.805, -1.4375,
|
||||
2.53125}, {0, -1.4375, 2.53125}, {1.5, 0, 2.4}, {1.5, -0.84,
|
||||
2.4}, {0.84, -1.5, 2.4}, {0, -1.5, 2.4}, {1.75, 0, 1.875},
|
||||
{1.75, -0.98, 1.875}, {0.98, -1.75, 1.875}, {0, -1.75,
|
||||
1.875}, {2, 0, 1.35}, {2, -1.12, 1.35}, {1.12, -2, 1.35},
|
||||
{0, -2, 1.35}, {2, 0, 0.9}, {2, -1.12, 0.9}, {1.12, -2,
|
||||
0.9}, {0, -2, 0.9}, {-2, 0, 0.9}, {2, 0, 0.45}, {2, -1.12,
|
||||
0.45}, {1.12, -2, 0.45}, {0, -2, 0.45}, {1.5, 0, 0.225},
|
||||
{1.5, -0.84, 0.225}, {0.84, -1.5, 0.225}, {0, -1.5, 0.225},
|
||||
{1.5, 0, 0.15}, {1.5, -0.84, 0.15}, {0.84, -1.5, 0.15}, {0,
|
||||
-1.5, 0.15}, {-1.6, 0, 2.025}, {-1.6, -0.3, 2.025}, {-1.5,
|
||||
-0.3, 2.25}, {-1.5, 0, 2.25}, {-2.3, 0, 2.025}, {-2.3, -0.3,
|
||||
2.025}, {-2.5, -0.3, 2.25}, {-2.5, 0, 2.25}, {-2.7, 0,
|
||||
2.025}, {-2.7, -0.3, 2.025}, {-3, -0.3, 2.25}, {-3, 0,
|
||||
2.25}, {-2.7, 0, 1.8}, {-2.7, -0.3, 1.8}, {-3, -0.3, 1.8},
|
||||
{-3, 0, 1.8}, {-2.7, 0, 1.575}, {-2.7, -0.3, 1.575}, {-3,
|
||||
-0.3, 1.35}, {-3, 0, 1.35}, {-2.5, 0, 1.125}, {-2.5, -0.3,
|
||||
1.125}, {-2.65, -0.3, 0.9375}, {-2.65, 0, 0.9375}, {-2,
|
||||
-0.3, 0.9}, {-1.9, -0.3, 0.6}, {-1.9, 0, 0.6}, {1.7, 0,
|
||||
1.425}, {1.7, -0.66, 1.425}, {1.7, -0.66, 0.6}, {1.7, 0,
|
||||
0.6}, {2.6, 0, 1.425}, {2.6, -0.66, 1.425}, {3.1, -0.66,
|
||||
0.825}, {3.1, 0, 0.825}, {2.3, 0, 2.1}, {2.3, -0.25, 2.1},
|
||||
{2.4, -0.25, 2.025}, {2.4, 0, 2.025}, {2.7, 0, 2.4}, {2.7,
|
||||
-0.25, 2.4}, {3.3, -0.25, 2.4}, {3.3, 0, 2.4}, {2.8, 0,
|
||||
2.475}, {2.8, -0.25, 2.475}, {3.525, -0.25, 2.49375},
|
||||
{3.525, 0, 2.49375}, {2.9, 0, 2.475}, {2.9, -0.15, 2.475},
|
||||
{3.45, -0.15, 2.5125}, {3.45, 0, 2.5125}, {2.8, 0, 2.4},
|
||||
{2.8, -0.15, 2.4}, {3.2, -0.15, 2.4}, {3.2, 0, 2.4}, {0, 0,
|
||||
3.15}, {0.8, 0, 3.15}, {0.8, -0.45, 3.15}, {0.45, -0.8,
|
||||
3.15}, {0, -0.8, 3.15}, {0, 0, 2.85}, {1.4, 0, 2.4}, {1.4,
|
||||
-0.784, 2.4}, {0.784, -1.4, 2.4}, {0, -1.4, 2.4}, {0.4, 0,
|
||||
2.55}, {0.4, -0.224, 2.55}, {0.224, -0.4, 2.55}, {0, -0.4,
|
||||
2.55}, {1.3, 0, 2.55}, {1.3, -0.728, 2.55}, {0.728, -1.3,
|
||||
2.55}, {0, -1.3, 2.55}, {1.3, 0, 2.4}, {1.3, -0.728, 2.4},
|
||||
{0.728, -1.3, 2.4}, {0, -1.3, 2.4}, {0, 0, 0}, {1.425,
|
||||
-0.798, 0}, {1.5, 0, 0.075}, {1.425, 0, 0}, {0.798, -1.425,
|
||||
0}, {0, -1.5, 0.075}, {0, -1.425, 0}, {1.5, -0.84, 0.075},
|
||||
{0.84, -1.5, 0.075}
|
||||
};
|
||||
|
||||
static float tex[2][2][2] =
|
||||
{
|
||||
{ {0, 0},
|
||||
{1, 0}},
|
||||
{ {0, 1},
|
||||
{1, 1}}
|
||||
};
|
||||
|
||||
/* *INDENT-ON* */
|
||||
|
||||
static void
|
||||
teapot(GLint grid, GLdouble scale, GLenum type)
|
||||
{
|
||||
float p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3];
|
||||
long i, j, k, l;
|
||||
|
||||
glPushAttrib(GL_ENABLE_BIT | GL_EVAL_BIT);
|
||||
glEnable(GL_AUTO_NORMAL);
|
||||
glEnable(GL_NORMALIZE);
|
||||
glEnable(GL_MAP2_VERTEX_3);
|
||||
glEnable(GL_MAP2_TEXTURE_COORD_2);
|
||||
glPushMatrix();
|
||||
glRotatef(270.0, 1.0, 0.0, 0.0);
|
||||
glScalef(0.5 * scale, 0.5 * scale, 0.5 * scale);
|
||||
glTranslatef(0.0, 0.0, -1.5);
|
||||
for (i = 0; i < 10; i++) {
|
||||
for (j = 0; j < 4; j++) {
|
||||
for (k = 0; k < 4; k++) {
|
||||
for (l = 0; l < 3; l++) {
|
||||
p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
|
||||
q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l];
|
||||
if (l == 1)
|
||||
q[j][k][l] *= -1.0;
|
||||
if (i < 6) {
|
||||
r[j][k][l] =
|
||||
cpdata[patchdata[i][j * 4 + (3 - k)]][l];
|
||||
if (l == 0)
|
||||
r[j][k][l] *= -1.0;
|
||||
s[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
|
||||
if (l == 0)
|
||||
s[j][k][l] *= -1.0;
|
||||
if (l == 1)
|
||||
s[j][k][l] *= -1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2,
|
||||
&tex[0][0][0]);
|
||||
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
|
||||
&p[0][0][0]);
|
||||
glMapGrid2f(grid, 0.0, 1.0, grid, 0.0, 1.0);
|
||||
glEvalMesh2(type, 0, grid, 0, grid);
|
||||
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
|
||||
&q[0][0][0]);
|
||||
glEvalMesh2(type, 0, grid, 0, grid);
|
||||
if (i < 6) {
|
||||
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
|
||||
&r[0][0][0]);
|
||||
glEvalMesh2(type, 0, grid, 0, grid);
|
||||
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
|
||||
&s[0][0][0]);
|
||||
glEvalMesh2(type, 0, grid, 0, grid);
|
||||
}
|
||||
}
|
||||
glPopMatrix();
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY
|
||||
glutSolidTeapot(GLdouble scale)
|
||||
{
|
||||
teapot(7, scale, GL_FILL);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutWireTeapot(GLdouble scale)
|
||||
{
|
||||
teapot(10, scale, GL_LINE);
|
||||
}
|
||||
|
||||
/* ENDCENTRY */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,90 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1994. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "glutint.h"
|
||||
|
||||
#if !defined(__OS2__)
|
||||
|
||||
/* strdup is actually not a standard ANSI C or POSIX routine
|
||||
so implement a private one for GLUT. OpenVMS does not have a
|
||||
strdup; Linux's standard libc doesn't declare strdup by default
|
||||
(unless BSD or SVID interfaces are requested). */
|
||||
char *
|
||||
__glutStrdup(const char *string)
|
||||
{
|
||||
char *copy;
|
||||
|
||||
copy = (char*) malloc(strlen(string) + 1);
|
||||
if (copy == NULL)
|
||||
return NULL;
|
||||
strcpy(copy, string);
|
||||
return copy;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
__glutWarning(char *format,...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
fprintf(stderr, "GLUT: Warning in %s: ",
|
||||
__glutProgramName ? __glutProgramName : "(unamed)");
|
||||
vfprintf(stderr, format, args);
|
||||
va_end(args);
|
||||
putc('\n', stderr);
|
||||
}
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY
|
||||
glutReportErrors(void)
|
||||
{
|
||||
GLenum error;
|
||||
|
||||
while ((error = glGetError()) != GL_NO_ERROR)
|
||||
__glutWarning("GL error: %s", gluErrorString(error));
|
||||
}
|
||||
/* ENDCENTRY */
|
||||
|
||||
void
|
||||
__glutFatalError(char *format,...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
fprintf(stderr, "GLUT: Fatal Error in %s: ",
|
||||
__glutProgramName ? __glutProgramName : "(unamed)");
|
||||
vfprintf(stderr, format, args);
|
||||
va_end(args);
|
||||
putc('\n', stderr);
|
||||
/* || defined(__OS2__) */
|
||||
#if defined(_WIN32)
|
||||
if (__glutExitFunc) {
|
||||
__glutExitFunc(1);
|
||||
}
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
__glutFatalUsage(char *format,...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
fprintf(stderr, "GLUT: Fatal API Usage in %s: ",
|
||||
__glutProgramName ? __glutProgramName : "(unamed)");
|
||||
vfprintf(stderr, format, args);
|
||||
va_end(args);
|
||||
putc('\n', stderr);
|
||||
abort();
|
||||
}
|
|
@ -0,0 +1,232 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1996. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __sgi
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#include "glutint.h"
|
||||
|
||||
/* Grumble. The IRIX 6.3 and early IRIX 6.4 OpenGL headers
|
||||
support the video resize extension, but failed to define
|
||||
GLX_SGIX_video_resize. */
|
||||
#if 0
|
||||
#ifdef GLX_SYNC_FRAME_SGIX
|
||||
#define GLX_SGIX_video_resize 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
|
||||
static int canVideoResize = -1;
|
||||
static int videoResizeChannel;
|
||||
#else
|
||||
static int canVideoResize = 0;
|
||||
#endif
|
||||
static int videoResizeInUse = 0;
|
||||
static int dx = -1, dy = -1, dw = -1, dh = -1;
|
||||
|
||||
/* XXX Note that IRIX 6.2, 6.3, and some 6.4 versions have a
|
||||
bug where programs seg-fault when they attempt video
|
||||
resizing from an indirect OpenGL context (either local or
|
||||
over a network). */
|
||||
|
||||
#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
|
||||
|
||||
static volatile int errorCaught;
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
catchXSGIvcErrors(Display * dpy, XErrorEvent * event)
|
||||
{
|
||||
errorCaught = 1;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* CENTRY */
|
||||
|
||||
int GLUTAPIENTRY
|
||||
glutVideoResizeGet(GLenum param)
|
||||
{
|
||||
#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
|
||||
if (canVideoResize < 0) {
|
||||
canVideoResize = __glutIsSupportedByGLX("GLX_SGIX_video_resize");
|
||||
if (canVideoResize) {
|
||||
#if defined(__sgi) && __sgi
|
||||
/* This is a hack because IRIX 6.2, 6.3, and some 6.4
|
||||
versions were released with GLX_SGIX_video_resize
|
||||
being advertised by the X server though the video
|
||||
resize extension is not actually supported. We try to
|
||||
determine if the libGL.so we are using actually has a
|
||||
video resize entrypoint before we try to use the
|
||||
feature. */
|
||||
void (*func) (void);
|
||||
void *glxDso = dlopen("libGL.so", RTLD_LAZY);
|
||||
|
||||
func = (void (*)(void)) dlsym(glxDso, "glXQueryChannelDeltasSGIX");
|
||||
if (!func) {
|
||||
canVideoResize = 0;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
char *channelString;
|
||||
int (*handler) (Display *, XErrorEvent *);
|
||||
|
||||
channelString = getenv("GLUT_VIDEO_RESIZE_CHANNEL");
|
||||
videoResizeChannel = channelString ? atoi(channelString) : 0;
|
||||
|
||||
/* Work around another annoying problem with SGI's
|
||||
GLX_SGIX_video_resize implementation. Early IRIX
|
||||
6.4 OpenGL's advertise the extension and have the
|
||||
video resize API, but an XSGIvc X protocol errors
|
||||
result trying to use the API. Set up an error
|
||||
handler to intercept what would otherwise be a fatal
|
||||
error. If an error was recieved, do not report that
|
||||
video resize is possible. */
|
||||
handler = XSetErrorHandler(catchXSGIvcErrors);
|
||||
|
||||
errorCaught = 0;
|
||||
|
||||
#if defined(GLX_GLXEXT_PROTOTYPES)
|
||||
#endif
|
||||
|
||||
__glut_glXQueryChannelDeltasSGIX(__glutDisplay, __glutScreen,
|
||||
videoResizeChannel, &dx, &dy, &dw, &dh);
|
||||
|
||||
/* glXQueryChannelDeltasSGIX is an inherent X server
|
||||
round-trip so we know we will have gotten either the
|
||||
correct reply or and error by this time. */
|
||||
XSetErrorHandler(handler);
|
||||
|
||||
/* Still yet another work around. In IRIX 6.4 betas,
|
||||
glXQueryChannelDeltasSGIX will return as if it
|
||||
succeeded, but the values are filled with junk.
|
||||
Watch to make sure the delta variables really make
|
||||
sense. */
|
||||
if (errorCaught ||
|
||||
dx < 0 || dy < 0 || dw < 0 || dh < 0 ||
|
||||
dx > 2048 || dy > 2048 || dw > 2048 || dh > 2048) {
|
||||
canVideoResize = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* GLX_SGIX_video_resize */
|
||||
|
||||
switch (param) {
|
||||
case GLUT_VIDEO_RESIZE_POSSIBLE:
|
||||
return canVideoResize;
|
||||
case GLUT_VIDEO_RESIZE_IN_USE:
|
||||
return videoResizeInUse;
|
||||
case GLUT_VIDEO_RESIZE_X_DELTA:
|
||||
return dx;
|
||||
case GLUT_VIDEO_RESIZE_Y_DELTA:
|
||||
return dy;
|
||||
case GLUT_VIDEO_RESIZE_WIDTH_DELTA:
|
||||
return dw;
|
||||
case GLUT_VIDEO_RESIZE_HEIGHT_DELTA:
|
||||
return dh;
|
||||
case GLUT_VIDEO_RESIZE_X:
|
||||
case GLUT_VIDEO_RESIZE_Y:
|
||||
case GLUT_VIDEO_RESIZE_WIDTH:
|
||||
case GLUT_VIDEO_RESIZE_HEIGHT:
|
||||
#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
|
||||
if (videoResizeInUse) {
|
||||
int x, y, width, height;
|
||||
|
||||
__glut_glXQueryChannelRectSGIX(__glutDisplay, __glutScreen,
|
||||
videoResizeChannel, &x, &y, &width, &height);
|
||||
switch (param) {
|
||||
case GLUT_VIDEO_RESIZE_X:
|
||||
return x;
|
||||
case GLUT_VIDEO_RESIZE_Y:
|
||||
return y;
|
||||
case GLUT_VIDEO_RESIZE_WIDTH:
|
||||
return width;
|
||||
case GLUT_VIDEO_RESIZE_HEIGHT:
|
||||
return height;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return -1;
|
||||
default:
|
||||
__glutWarning("invalid glutVideoResizeGet parameter: %d", param);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutSetupVideoResizing(void)
|
||||
{
|
||||
#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
|
||||
if (glutVideoResizeGet(GLUT_VIDEO_RESIZE_POSSIBLE)) {
|
||||
__glut_glXBindChannelToWindowSGIX(__glutDisplay, __glutScreen,
|
||||
videoResizeChannel, __glutCurrentWindow->win);
|
||||
videoResizeInUse = 1;
|
||||
} else
|
||||
#endif
|
||||
__glutFatalError("glutEstablishVideoResizing: video resizing not possible.\n");
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutStopVideoResizing(void)
|
||||
{
|
||||
#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
|
||||
if (glutVideoResizeGet(GLUT_VIDEO_RESIZE_POSSIBLE)) {
|
||||
if (videoResizeInUse) {
|
||||
__glut_glXBindChannelToWindowSGIX(__glutDisplay, __glutScreen,
|
||||
videoResizeChannel, None);
|
||||
videoResizeInUse = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
void GLUTAPIENTRY
|
||||
glutVideoResize(int x, int y, int width, int height)
|
||||
{
|
||||
#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
|
||||
if (videoResizeInUse) {
|
||||
#ifdef GLX_SYNC_SWAP_SGIX
|
||||
/* glXChannelRectSyncSGIX introduced in a patch to IRIX
|
||||
6.2; the original unpatched IRIX 6.2 behavior is always
|
||||
GLX_SYNC_SWAP_SGIX. */
|
||||
__glut_glXChannelRectSyncSGIX(__glutDisplay, __glutScreen,
|
||||
videoResizeChannel, GLX_SYNC_SWAP_SGIX);
|
||||
#endif
|
||||
__glut_glXChannelRectSGIX(__glutDisplay, __glutScreen,
|
||||
videoResizeChannel, x, y, width, height);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
void GLUTAPIENTRY
|
||||
glutVideoPan(int x, int y, int width, int height)
|
||||
{
|
||||
#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_video_resize)
|
||||
if (videoResizeInUse) {
|
||||
#ifdef GLX_SYNC_FRAME_SGIX
|
||||
/* glXChannelRectSyncSGIX introduced in a patch to IRIX
|
||||
6.2; the original unpatched IRIX 6.2 behavior is always
|
||||
GLX_SYNC_SWAP_SGIX. We just ignore that we cannot
|
||||
accomplish GLX_SYNC_FRAME_SGIX on IRIX unpatched 6.2;
|
||||
this means you'd need a glutSwapBuffers to actually
|
||||
realize the video resize. */
|
||||
__glut_glXChannelRectSyncSGIX(__glutDisplay, __glutScreen,
|
||||
videoResizeChannel, GLX_SYNC_FRAME_SGIX);
|
||||
#endif
|
||||
__glut_glXChannelRectSGIX(__glutDisplay, __glutScreen,
|
||||
videoResizeChannel, x, y, width, height);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ENDCENTRY */
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1996, 1997. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "glutint.h"
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY
|
||||
glutWarpPointer(int x, int y)
|
||||
{
|
||||
// XWarpPointer(__glutDisplay, None, __glutCurrentWindow->win,
|
||||
// 0, 0, 0, 0, x, y);
|
||||
POINTL point;
|
||||
point.x = x;
|
||||
point.y = y;
|
||||
WinMapWindowPoints(__glutCurrentWindow->win,HWND_DESKTOP,&point,1);
|
||||
WinSetPointerPos(HWND_DESKTOP, point.x, point.y);
|
||||
|
||||
XFlush(__glutDisplay);
|
||||
}
|
||||
|
||||
/* ENDCENTRY */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,127 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1994. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#include "glutint.h"
|
||||
|
||||
/* CENTRY */
|
||||
void GLUTAPIENTRY
|
||||
glutSetWindowTitle(const char *title)
|
||||
{
|
||||
#if defined(__OS2PM__)
|
||||
__glutSetWindowText(__glutCurrentWindow->win, (char *)title);
|
||||
|
||||
#else
|
||||
XTextProperty textprop;
|
||||
|
||||
assert(!__glutCurrentWindow->parent);
|
||||
IGNORE_IN_GAME_MODE();
|
||||
textprop.value = (unsigned char *) title;
|
||||
textprop.encoding = XA_STRING;
|
||||
textprop.format = 8;
|
||||
textprop.nitems = strlen(title);
|
||||
XSetWMName(__glutDisplay,
|
||||
__glutCurrentWindow->win, &textprop);
|
||||
XFlush(__glutDisplay);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutSetIconTitle(const char *title)
|
||||
{
|
||||
#if defined(__OS2PM__)
|
||||
//todo ?
|
||||
#else
|
||||
|
||||
XTextProperty textprop;
|
||||
|
||||
assert(!__glutCurrentWindow->parent);
|
||||
IGNORE_IN_GAME_MODE();
|
||||
textprop.value = (unsigned char *) title;
|
||||
textprop.encoding = XA_STRING;
|
||||
textprop.format = 8;
|
||||
textprop.nitems = strlen(title);
|
||||
XSetWMIconName(__glutDisplay,
|
||||
__glutCurrentWindow->win, &textprop);
|
||||
XFlush(__glutDisplay);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutPositionWindow(int x, int y)
|
||||
{
|
||||
IGNORE_IN_GAME_MODE();
|
||||
__glutCurrentWindow->desiredX = x;
|
||||
__glutCurrentWindow->desiredY = y;
|
||||
__glutCurrentWindow->desiredConfMask |= CWX | CWY;
|
||||
__glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutReshapeWindow(int w, int h)
|
||||
{
|
||||
IGNORE_IN_GAME_MODE();
|
||||
if (w <= 0 || h <= 0)
|
||||
__glutWarning("glutReshapeWindow: non-positive width or height not allowed");
|
||||
|
||||
__glutCurrentWindow->desiredWidth = w;
|
||||
__glutCurrentWindow->desiredHeight = h;
|
||||
__glutCurrentWindow->desiredConfMask |= CWWidth | CWHeight;
|
||||
__glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutPopWindow(void)
|
||||
{
|
||||
IGNORE_IN_GAME_MODE();
|
||||
__glutCurrentWindow->desiredStack = Above;
|
||||
__glutCurrentWindow->desiredConfMask |= CWStackMode;
|
||||
__glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutPushWindow(void)
|
||||
{
|
||||
IGNORE_IN_GAME_MODE();
|
||||
__glutCurrentWindow->desiredStack = Below;
|
||||
__glutCurrentWindow->desiredConfMask |= CWStackMode;
|
||||
__glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutIconifyWindow(void)
|
||||
{
|
||||
IGNORE_IN_GAME_MODE();
|
||||
assert(!__glutCurrentWindow->parent);
|
||||
__glutCurrentWindow->desiredMapState = IconicState;
|
||||
__glutPutOnWorkList(__glutCurrentWindow, GLUT_MAP_WORK);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutShowWindow(void)
|
||||
{
|
||||
IGNORE_IN_GAME_MODE();
|
||||
__glutCurrentWindow->desiredMapState = NormalState;
|
||||
__glutPutOnWorkList(__glutCurrentWindow, GLUT_MAP_WORK);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutHideWindow(void)
|
||||
{
|
||||
IGNORE_IN_GAME_MODE();
|
||||
__glutCurrentWindow->desiredMapState = WithdrawnState;
|
||||
__glutPutOnWorkList(__glutCurrentWindow, GLUT_MAP_WORK);
|
||||
}
|
||||
|
||||
/* ENDCENTRY */
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
#ifndef __glutbitmap_h__
|
||||
#define __glutbitmap_h__
|
||||
|
||||
/* Copyright (c) Mark J. Kilgard, 1994, 1998. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#define GLUT_NO_LIB_PRAGMA /* Avoid auto library linking when building
|
||||
the GLUT library itself. */
|
||||
#include <GL/glut.h>
|
||||
|
||||
typedef struct {
|
||||
const GLsizei width;
|
||||
const GLsizei height;
|
||||
const GLfloat xorig;
|
||||
const GLfloat yorig;
|
||||
const GLfloat advance;
|
||||
const GLubyte *bitmap;
|
||||
} BitmapCharRec, *BitmapCharPtr;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const int num_chars;
|
||||
const int first;
|
||||
const BitmapCharRec * const *ch;
|
||||
} BitmapFontRec, *BitmapFontPtr;
|
||||
|
||||
typedef void *GLUTbitmapFont;
|
||||
|
||||
#endif /* __glutbitmap_h__ */
|
|
@ -0,0 +1,36 @@
|
|||
#ifndef __glutos2_h__
|
||||
#define __glutos2_h__
|
||||
|
||||
|
||||
/* Win32 "equivalent" cursors - eventually, the X glyphs should be
|
||||
converted to Win32 cursors -- then they will look the same */
|
||||
#define XC_arrow IDC_ARROW
|
||||
#define XC_top_left_arrow IDC_ARROW
|
||||
#define XC_hand1 IDC_SIZEALL
|
||||
#define XC_pirate IDC_NO
|
||||
#define XC_question_arrow IDC_HELP
|
||||
#define XC_exchange IDC_NO
|
||||
#define XC_spraycan IDC_SIZEALL
|
||||
#define XC_watch IDC_WAIT
|
||||
#define XC_xterm IDC_IBEAM
|
||||
#define XC_crosshair IDC_CROSS
|
||||
#define XC_sb_v_double_arrow IDC_SIZENS
|
||||
#define XC_sb_h_double_arrow IDC_SIZEWE
|
||||
#define XC_top_side IDC_UPARROW
|
||||
#define XC_bottom_side IDC_SIZENS
|
||||
#define XC_left_side IDC_SIZEWE
|
||||
#define XC_right_side IDC_SIZEWE
|
||||
#define XC_top_left_corner IDC_SIZENWSE
|
||||
#define XC_top_right_corner IDC_SIZENESW
|
||||
#define XC_bottom_right_corner IDC_SIZENWSE
|
||||
#define XC_bottom_left_corner IDC_SIZENESW
|
||||
|
||||
#define XA_STRING 0
|
||||
|
||||
/* Private routines from win32_util.c */
|
||||
extern int gettimeofday(struct timeval* tp, void* tzp);
|
||||
//extern void *__glutFont(void *font);
|
||||
extern int __glutGetTransparentPixel(Display *dpy, XVisualInfo *vinfo);
|
||||
extern void __glutAdjustCoords(Window parent, int *x, int *y, int *width, int *height);
|
||||
|
||||
#endif /* __glutos2_h__ */
|
|
@ -0,0 +1,42 @@
|
|||
#ifndef __glutstroke_h__
|
||||
#define __glutstroke_h__
|
||||
|
||||
/* Copyright (c) Mark J. Kilgard, 1994. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
#if defined(_WIN32)
|
||||
#pragma warning (disable:4244) /* disable bogus conversion warnings */
|
||||
#pragma warning (disable:4305) /* VC++ 5.0 version of above warning. */
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
float x;
|
||||
float y;
|
||||
} CoordRec, *CoordPtr;
|
||||
|
||||
typedef struct {
|
||||
int num_coords;
|
||||
const CoordRec *coord;
|
||||
} StrokeRec, *StrokePtr;
|
||||
|
||||
typedef struct {
|
||||
int num_strokes;
|
||||
const StrokeRec *stroke;
|
||||
float center;
|
||||
float right;
|
||||
} StrokeCharRec, *StrokeCharPtr;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
int num_chars;
|
||||
const StrokeCharRec *ch;
|
||||
float top;
|
||||
float bottom;
|
||||
} StrokeFontRec, *StrokeFontPtr;
|
||||
|
||||
typedef void *GLUTstrokeFont;
|
||||
|
||||
#endif /* __glutstroke_h__ */
|
|
@ -0,0 +1,59 @@
|
|||
#ifndef __layerutil_h__
|
||||
#define __layerutil_h__
|
||||
|
||||
/* Copyright (c) Mark J. Kilgard, 1993, 1994. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
/* Based on XLayerUtil.h: Revision: 1.3 */
|
||||
|
||||
#ifdef __VMS
|
||||
#include <GL/vms_x_fix.h>
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) && !defined(__OS2__)
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xmd.h>
|
||||
#endif /* !_WIN32 */
|
||||
|
||||
/* Transparent type values */
|
||||
/* None 0 */
|
||||
#define TransparentPixel 1
|
||||
#define TransparentMask 2
|
||||
|
||||
/* layered visual info template flags */
|
||||
#define VisualLayerMask 0x200
|
||||
#define VisualTransparentType 0x400
|
||||
#define VisualTransparentValue 0x800
|
||||
#define VisualAllLayerMask 0xFFF
|
||||
|
||||
/* layered visual info structure */
|
||||
typedef struct _XLayerVisualInfo {
|
||||
XVisualInfo vinfo;
|
||||
long layer;
|
||||
long type;
|
||||
unsigned long value;
|
||||
} XLayerVisualInfo;
|
||||
|
||||
/* SERVER_OVERLAY_VISUALS property element */
|
||||
typedef struct _OverlayInfo {
|
||||
/* Avoid 64-bit portability problems by being careful to use
|
||||
longs due to the way XGetWindowProperty is specified. Note
|
||||
that these parameters are passed as CARD32s over X
|
||||
protocol. */
|
||||
long overlay_visual;
|
||||
long transparent_type;
|
||||
long value;
|
||||
long layer;
|
||||
} OverlayInfo;
|
||||
|
||||
extern int __glutGetTransparentPixel(Display *, XVisualInfo *);
|
||||
extern XLayerVisualInfo *__glutXGetLayerVisualInfo(Display *,
|
||||
long, XLayerVisualInfo *, int *);
|
||||
extern Status __glutXMatchLayerVisualInfo(Display *,
|
||||
int, int, int, int, XLayerVisualInfo *);
|
||||
|
||||
#endif /* __layerutil_h__ */
|
|
@ -0,0 +1,94 @@
|
|||
|
||||
;-----------------------------------------------------
|
||||
; def Module definition file for the DLL
|
||||
;-----------------------------------------------------
|
||||
|
||||
LIBRARY libGlut INITINSTANCE TERMINSTANCE
|
||||
PROTMODE
|
||||
DATA MULTIPLE NONSHARED READWRITE LOADONCALL
|
||||
CODE LOADONCALL
|
||||
EXPORTS ; Names of exported functions and data
|
||||
|
||||
;*********************************
|
||||
;MesaGLUT
|
||||
glutCommandFunc @3001
|
||||
glutCreateWindow @3002
|
||||
glutCreateSubWindow @3003
|
||||
glutDestroyWindow @3004
|
||||
glutDisplayFunc @3005
|
||||
glutEntryFunc @3006
|
||||
glutExtensionSupported @3007
|
||||
glutIdleFunc @3008
|
||||
glutInit @3009
|
||||
glutInitDisplayMode @3010
|
||||
glutInitWindowPosition @3011
|
||||
glutInitWindowSize @3012
|
||||
glutMainLoop @3013
|
||||
glutGet @3014
|
||||
glutGetColor @3015
|
||||
glutGetWindow @3016
|
||||
glutKeyboardFunc @3017
|
||||
glutMouseFunc @3018
|
||||
glutSpecialFunc @3019
|
||||
glutStrokeCharacter @3020
|
||||
glutSetColor @3021
|
||||
glutSetIconTitle @3022
|
||||
glutSetWindow @3023
|
||||
glutSetWindowTitle @3024
|
||||
|
||||
glutReshapeFunc @3025
|
||||
glutReshapeWindow @3026
|
||||
|
||||
|
||||
glutSwapBuffers @3027
|
||||
glutPostRedisplay @3028
|
||||
glutPositionWindow @3029
|
||||
glutVisibilityFunc @3030
|
||||
glutTimerFunc @3031
|
||||
glutMotionFunc @3032
|
||||
|
||||
glutCreateMenu @3033
|
||||
glutAttachMenu @3034
|
||||
glutDestroyMenu @3035
|
||||
glutAddMenuEntry @3036
|
||||
glutPassiveMotionFunc @3037
|
||||
|
||||
glutSolidCone @3038
|
||||
glutSolidCube @3039
|
||||
glutSolidDodecahedron @3040
|
||||
glutSolidOctahedron @3041
|
||||
glutSolidIcosahedron @3042
|
||||
glutSolidSphere @3043
|
||||
glutSolidTeapot @3044
|
||||
glutSolidTetrahedron @3045
|
||||
glutSolidTorus @3046
|
||||
|
||||
glutWireCone @3047
|
||||
glutWireCube @3048
|
||||
glutWireDodecahedron @3049
|
||||
glutWireIcosahedron @3050
|
||||
glutWireOctahedron @3051
|
||||
glutWireSphere @3052
|
||||
glutWireTetrahedron @3053
|
||||
glutWireTorus @3054
|
||||
glutWireTeapot @3055
|
||||
|
||||
;GL_GLEXT_PROTOTYPES
|
||||
glutBitmapCharacter @3101
|
||||
glutBitmap9By15 @3102
|
||||
glutBitmapHelvetica10 @3103
|
||||
glutBitmapHelvetica12 @3104
|
||||
glutBitmapHelvetica18 @3105
|
||||
glutBitmapTimesRoman24 @3106
|
||||
glutStrokeRoman @3107
|
||||
glutBitmap8By13 @3108
|
||||
|
||||
;Global constants
|
||||
; hab @12001
|
||||
; /* PM anchor block handle */
|
||||
; hpsCurrent @12002
|
||||
XHDC @12004
|
||||
XHWND @12005
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
/* os2_glx.c */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include "gl/gl.h"
|
||||
#include "WarpGL.h"
|
||||
#include "GL/os2mesa.h"
|
||||
|
||||
#define POKA 0
|
||||
/* global current HDC */
|
||||
|
||||
XVisualInfo *wglDescribePixelFormat(int iPixelFormat);
|
||||
|
||||
extern HDC XHDC;
|
||||
extern HWND XHWND;
|
||||
//extern HPS hpsCurrent;
|
||||
extern HAB hab; /* PM anchor block handle */
|
||||
|
||||
GLXContext
|
||||
glXCreateContext(HPS hps, XVisualInfo * visinfo,
|
||||
GLXContext share, Bool direct)
|
||||
{
|
||||
/* KLUDGE: GLX really expects a display pointer to be passed
|
||||
in as the first parameter, but Win32 needs an HDC instead,
|
||||
so BE SURE that the global XHDC is set before calling this
|
||||
routine. */
|
||||
HGLRC context;
|
||||
|
||||
context = wglCreateContext(XHDC,hps,hab);
|
||||
|
||||
|
||||
/* Since direct rendering is implicit, the direct flag is
|
||||
ignored. */
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
glXGetConfig(XVisualInfo * visual, int attrib, int *value)
|
||||
{
|
||||
if (!visual)
|
||||
return GLX_BAD_VISUAL;
|
||||
|
||||
switch (attrib) {
|
||||
case GLX_USE_GL:
|
||||
if (visual->dwFlags & (PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW)) {
|
||||
/* XXX Brad's Matrix Millenium II has problems creating
|
||||
color index windows in 24-bit mode (lead to GDI crash)
|
||||
and 32-bit mode (lead to black window). The cColorBits
|
||||
filed of the PIXELFORMATDESCRIPTOR returned claims to
|
||||
have 24 and 32 bits respectively of color indices. 2^24
|
||||
and 2^32 are ridiculously huge writable colormaps.
|
||||
Assume that if we get back a color index
|
||||
PIXELFORMATDESCRIPTOR with 24 or more bits, the
|
||||
PIXELFORMATDESCRIPTOR doesn't really work and skip it.
|
||||
-mjk */
|
||||
if (visual->iPixelType == PFD_TYPE_COLORINDEX
|
||||
&& visual->cColorBits >= 24) {
|
||||
*value = 0;
|
||||
} else {
|
||||
*value = 1;
|
||||
}
|
||||
} else {
|
||||
*value = 0;
|
||||
}
|
||||
break;
|
||||
case GLX_BUFFER_SIZE:
|
||||
/* KLUDGE: if we're RGBA, return the number of bits/pixel,
|
||||
otherwise, return 8 (we guessed at 256 colors in CI
|
||||
mode). */
|
||||
if (visual->iPixelType == PFD_TYPE_RGBA)
|
||||
*value = visual->cColorBits;
|
||||
else
|
||||
*value = 8;
|
||||
break;
|
||||
case GLX_LEVEL:
|
||||
/* The bReserved flag of the pfd contains the
|
||||
overlay/underlay info. */
|
||||
*value = visual->bReserved;
|
||||
break;
|
||||
case GLX_RGBA:
|
||||
*value = visual->iPixelType == PFD_TYPE_RGBA;
|
||||
break;
|
||||
case GLX_DOUBLEBUFFER:
|
||||
*value = visual->dwFlags & PFD_DOUBLEBUFFER;
|
||||
break;
|
||||
case GLX_STEREO:
|
||||
*value = visual->dwFlags & PFD_STEREO;
|
||||
break;
|
||||
case GLX_AUX_BUFFERS:
|
||||
*value = visual->cAuxBuffers;
|
||||
break;
|
||||
case GLX_RED_SIZE:
|
||||
*value = visual->cRedBits;
|
||||
break;
|
||||
case GLX_GREEN_SIZE:
|
||||
*value = visual->cGreenBits;
|
||||
break;
|
||||
case GLX_BLUE_SIZE:
|
||||
*value = visual->cBlueBits;
|
||||
break;
|
||||
case GLX_ALPHA_SIZE:
|
||||
*value = visual->cAlphaBits;
|
||||
break;
|
||||
case GLX_DEPTH_SIZE:
|
||||
*value = visual->cDepthBits;
|
||||
break;
|
||||
case GLX_STENCIL_SIZE:
|
||||
*value = visual->cStencilBits;
|
||||
break;
|
||||
case GLX_ACCUM_RED_SIZE:
|
||||
*value = visual->cAccumRedBits;
|
||||
break;
|
||||
case GLX_ACCUM_GREEN_SIZE:
|
||||
*value = visual->cAccumGreenBits;
|
||||
break;
|
||||
case GLX_ACCUM_BLUE_SIZE:
|
||||
*value = visual->cAccumBlueBits;
|
||||
break;
|
||||
case GLX_ACCUM_ALPHA_SIZE:
|
||||
*value = visual->cAccumAlphaBits;
|
||||
break;
|
||||
#if POKA == 100
|
||||
#endif /* POKA == 100 */
|
||||
default:
|
||||
return GLX_BAD_ATTRIB;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
XVisualInfo * glXChooseVisual(int mode)
|
||||
{ int imode = 2;
|
||||
if(mode & GLUT_DOUBLE)
|
||||
imode = 1;
|
||||
return
|
||||
wglDescribePixelFormat(imode);
|
||||
}
|
||||
|
||||
|
||||
#if POKA
|
||||
#endif /* POKA */
|
||||
|
||||
|
|
@ -0,0 +1,533 @@
|
|||
|
||||
/* Copyright (c) Mark J. Kilgard, 1994, 1997, 1998. */
|
||||
/* Copyright (c) Nate Robins, 1997. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
/* This file completely re-implements glut_menu.c and glut_menu2.c
|
||||
for Win32. Note that neither glut_menu.c nor glut_menu2.c are
|
||||
compiled into Win32 GLUT. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "glutint.h"
|
||||
|
||||
void (GLUTCALLBACK *__glutMenuStatusFunc) (int, int, int);
|
||||
//GLUTmenu *__glutMappedMenu;
|
||||
//GLUTwindow *__glutMenuWindow;
|
||||
GLUTmenuItem *__glutItemSelected;
|
||||
unsigned __glutMenuButton;
|
||||
|
||||
static GLUTmenu **menuList = NULL;
|
||||
static int menuListSize = 0;
|
||||
static UINT uniqueMenuHandler = 1;
|
||||
|
||||
/* DEPRICATED, use glutMenuStatusFunc instead. */
|
||||
void GLUTAPIENTRY
|
||||
glutMenuStateFunc(GLUTmenuStateCB menuStateFunc)
|
||||
{
|
||||
__glutMenuStatusFunc = (GLUTmenuStatusCB) menuStateFunc;
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutMenuStatusFunc(GLUTmenuStatusCB menuStatusFunc)
|
||||
{
|
||||
__glutMenuStatusFunc = menuStatusFunc;
|
||||
}
|
||||
|
||||
void
|
||||
__glutSetMenu(GLUTmenu * menu)
|
||||
{
|
||||
__glutCurrentMenu = menu;
|
||||
}
|
||||
|
||||
static void
|
||||
unmapMenu(GLUTmenu * menu)
|
||||
{
|
||||
if (menu->cascade) {
|
||||
unmapMenu(menu->cascade);
|
||||
menu->cascade = NULL;
|
||||
}
|
||||
menu->anchor = NULL;
|
||||
menu->highlighted = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
__glutFinishMenu(Window win, int x, int y)
|
||||
{
|
||||
|
||||
unmapMenu(__glutMappedMenu);
|
||||
|
||||
/* XXX Put in a GdiFlush just in case. Probably unnecessary. -mjk */
|
||||
// GdiFlush();
|
||||
|
||||
if (__glutMenuStatusFunc) {
|
||||
__glutSetWindow(__glutMenuWindow);
|
||||
__glutSetMenu(__glutMappedMenu);
|
||||
|
||||
/* Setting __glutMappedMenu to NULL permits operations that
|
||||
change menus or destroy the menu window again. */
|
||||
__glutMappedMenu = NULL;
|
||||
|
||||
__glutMenuStatusFunc(GLUT_MENU_NOT_IN_USE, x, y);
|
||||
}
|
||||
/* Setting __glutMappedMenu to NULL permits operations that
|
||||
change menus or destroy the menu window again. */
|
||||
__glutMappedMenu = NULL;
|
||||
|
||||
/* If an item is selected and it is not a submenu trigger,
|
||||
generate menu callback. */
|
||||
if (__glutItemSelected && !__glutItemSelected->isTrigger) {
|
||||
__glutSetWindow(__glutMenuWindow);
|
||||
/* When menu callback is triggered, current menu should be
|
||||
set to the callback menu. */
|
||||
__glutSetMenu(__glutItemSelected->menu);
|
||||
__glutItemSelected->menu->select(__glutItemSelected->value);
|
||||
}
|
||||
__glutMenuWindow = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
mapMenu(GLUTmenu * menu, int x, int y)
|
||||
{
|
||||
//todo
|
||||
// TrackPopupMenu((HMENU) menu->win, TPM_LEFTALIGN |
|
||||
// (__glutMenuButton == TPM_RIGHTBUTTON) ? TPM_RIGHTBUTTON : TPM_LEFTBUTTON,
|
||||
// x, y, 0, __glutCurrentWindow->win, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
__glutStartMenu(GLUTmenu * menu, GLUTwindow * window,
|
||||
int x, int y, int x_win, int y_win)
|
||||
{
|
||||
assert(__glutMappedMenu == NULL);
|
||||
__glutMappedMenu = menu;
|
||||
__glutMenuWindow = window;
|
||||
__glutItemSelected = NULL;
|
||||
if (__glutMenuStatusFunc) {
|
||||
__glutSetMenu(menu);
|
||||
__glutSetWindow(window);
|
||||
__glutMenuStatusFunc(GLUT_MENU_IN_USE, x_win, y_win);
|
||||
}
|
||||
mapMenu(menu, x, y);
|
||||
}
|
||||
|
||||
GLUTmenuItem *
|
||||
__glutGetUniqueMenuItem(GLUTmenu * menu, UINT unique)
|
||||
{
|
||||
GLUTmenuItem *item;
|
||||
int i;
|
||||
|
||||
i = menu->num;
|
||||
item = menu->list;
|
||||
while (item) {
|
||||
if (item->unique == unique) {
|
||||
return item;
|
||||
}
|
||||
if (item->isTrigger) {
|
||||
GLUTmenuItem *subitem;
|
||||
subitem = __glutGetUniqueMenuItem(menuList[item->value], unique);
|
||||
if (subitem) {
|
||||
return subitem;
|
||||
}
|
||||
}
|
||||
i--;
|
||||
item = item->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GLUTmenuItem *
|
||||
__glutGetMenuItem(GLUTmenu * menu, Window win, int *which)
|
||||
{
|
||||
GLUTmenuItem *item;
|
||||
int i;
|
||||
|
||||
i = menu->num;
|
||||
item = menu->list;
|
||||
while (item) {
|
||||
if (item->win == win) {
|
||||
*which = i;
|
||||
return item;
|
||||
}
|
||||
if (item->isTrigger) {
|
||||
GLUTmenuItem *subitem;
|
||||
|
||||
subitem = __glutGetMenuItem(menuList[item->value],
|
||||
win, which);
|
||||
if (subitem) {
|
||||
return subitem;
|
||||
}
|
||||
}
|
||||
i--;
|
||||
item = item->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GLUTmenu *
|
||||
__glutGetMenu(Window win)
|
||||
{
|
||||
GLUTmenu *menu;
|
||||
|
||||
menu = __glutMappedMenu;
|
||||
while (menu) {
|
||||
if (win == menu->win) {
|
||||
return menu;
|
||||
}
|
||||
menu = menu->cascade;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GLUTmenu *
|
||||
__glutGetMenuByNum(int menunum)
|
||||
{
|
||||
if (menunum < 1 || menunum > menuListSize) {
|
||||
return NULL;
|
||||
}
|
||||
return menuList[menunum - 1];
|
||||
}
|
||||
|
||||
static int
|
||||
getUnusedMenuSlot(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Look for allocated, unused slot. */
|
||||
for (i = 0; i < menuListSize; i++) {
|
||||
if (!menuList[i]) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
/* Allocate a new slot. */
|
||||
menuListSize++;
|
||||
if (menuList) {
|
||||
menuList = (GLUTmenu **)
|
||||
realloc(menuList, menuListSize * sizeof(GLUTmenu *));
|
||||
} else {
|
||||
/* XXX Some realloc's do not correctly perform a malloc
|
||||
when asked to perform a realloc on a NULL pointer,
|
||||
though the ANSI C library spec requires this. */
|
||||
menuList = (GLUTmenu **) malloc(sizeof(GLUTmenu *));
|
||||
}
|
||||
if (!menuList) {
|
||||
__glutFatalError("out of memory.");
|
||||
}
|
||||
menuList[menuListSize - 1] = NULL;
|
||||
return menuListSize - 1;
|
||||
}
|
||||
|
||||
static void
|
||||
menuModificationError(void)
|
||||
{
|
||||
/* XXX Remove the warning after GLUT 3.0. */
|
||||
__glutWarning("The following is a new check for GLUT 3.0; update your code.");
|
||||
__glutFatalError("menu manipulation not allowed while menus in use.");
|
||||
}
|
||||
|
||||
int GLUTAPIENTRY
|
||||
glutCreateMenu(GLUTselectCB selectFunc)
|
||||
{
|
||||
GLUTmenu *menu;
|
||||
int menuid;
|
||||
|
||||
if (__glutMappedMenu) {
|
||||
menuModificationError();
|
||||
}
|
||||
menuid = getUnusedMenuSlot();
|
||||
menu = (GLUTmenu *) malloc(sizeof(GLUTmenu));
|
||||
if (!menu) {
|
||||
__glutFatalError("out of memory.");
|
||||
}
|
||||
menu->id = menuid;
|
||||
menu->num = 0;
|
||||
menu->submenus = 0;
|
||||
menu->select = selectFunc;
|
||||
menu->list = NULL;
|
||||
menu->cascade = NULL;
|
||||
menu->highlighted = NULL;
|
||||
menu->anchor = NULL;
|
||||
//todo
|
||||
// menu->win = (HWND) CreatePopupMenu();
|
||||
menuList[menuid] = menu;
|
||||
__glutSetMenu(menu);
|
||||
return menuid + 1;
|
||||
}
|
||||
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutDestroyMenu(int menunum)
|
||||
{
|
||||
GLUTmenu *menu = __glutGetMenuByNum(menunum);
|
||||
GLUTmenuItem *item, *next;
|
||||
|
||||
if (__glutMappedMenu) {
|
||||
menuModificationError();
|
||||
}
|
||||
assert(menu->id == menunum - 1);
|
||||
//todo DestroyMenu( (HMENU) menu->win);
|
||||
menuList[menunum - 1] = NULL;
|
||||
/* free all menu entries */
|
||||
item = menu->list;
|
||||
while (item) {
|
||||
assert(item->menu == menu);
|
||||
next = item->next;
|
||||
free(item->label);
|
||||
free(item);
|
||||
item = next;
|
||||
}
|
||||
if (__glutCurrentMenu == menu) {
|
||||
__glutCurrentMenu = NULL;
|
||||
}
|
||||
free(menu);
|
||||
}
|
||||
|
||||
int GLUTAPIENTRY
|
||||
glutGetMenu(void)
|
||||
{
|
||||
if (__glutCurrentMenu) {
|
||||
return __glutCurrentMenu->id + 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutSetMenu(int menuid)
|
||||
{
|
||||
GLUTmenu *menu;
|
||||
|
||||
if (menuid < 1 || menuid > menuListSize) {
|
||||
__glutWarning("glutSetMenu attempted on bogus menu.");
|
||||
return;
|
||||
}
|
||||
menu = menuList[menuid - 1];
|
||||
if (!menu) {
|
||||
__glutWarning("glutSetMenu attempted on bogus menu.");
|
||||
return;
|
||||
}
|
||||
__glutSetMenu(menu);
|
||||
}
|
||||
|
||||
static void
|
||||
setMenuItem(GLUTmenuItem * item, const char *label,
|
||||
int value, Bool isTrigger)
|
||||
{
|
||||
GLUTmenu *menu;
|
||||
|
||||
menu = item->menu;
|
||||
item->label = __glutStrdup(label);
|
||||
if (!item->label) {
|
||||
__glutFatalError("out of memory.");
|
||||
}
|
||||
item->isTrigger = isTrigger;
|
||||
item->len = (int) strlen(label);
|
||||
item->value = value;
|
||||
item->unique = uniqueMenuHandler++;
|
||||
//todo
|
||||
// if (isTrigger) {
|
||||
// AppendMenu((HMENU) menu->win, MF_POPUP, (UINT)item->win, label);
|
||||
// } else {
|
||||
// AppendMenu((HMENU) menu->win, MF_STRING, item->unique, label);
|
||||
// }
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutAddMenuEntry(const char *label, int value)
|
||||
{
|
||||
GLUTmenuItem *entry;
|
||||
|
||||
if (__glutMappedMenu) {
|
||||
menuModificationError();
|
||||
}
|
||||
entry = (GLUTmenuItem *) malloc(sizeof(GLUTmenuItem));
|
||||
if (!entry) {
|
||||
__glutFatalError("out of memory.");
|
||||
}
|
||||
entry->menu = __glutCurrentMenu;
|
||||
setMenuItem(entry, label, value, FALSE);
|
||||
__glutCurrentMenu->num++;
|
||||
entry->next = __glutCurrentMenu->list;
|
||||
__glutCurrentMenu->list = entry;
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutAddSubMenu(const char *label, int menu)
|
||||
{
|
||||
GLUTmenuItem *submenu;
|
||||
GLUTmenu *popupmenu;
|
||||
|
||||
if (__glutMappedMenu) {
|
||||
menuModificationError();
|
||||
}
|
||||
submenu = (GLUTmenuItem *) malloc(sizeof(GLUTmenuItem));
|
||||
if (!submenu) {
|
||||
__glutFatalError("out of memory.");
|
||||
}
|
||||
__glutCurrentMenu->submenus++;
|
||||
submenu->menu = __glutCurrentMenu;
|
||||
popupmenu = __glutGetMenuByNum(menu);
|
||||
if (popupmenu) {
|
||||
submenu->win = popupmenu->win;
|
||||
}
|
||||
setMenuItem(submenu, label, /* base 0 */ menu - 1, TRUE);
|
||||
__glutCurrentMenu->num++;
|
||||
submenu->next = __glutCurrentMenu->list;
|
||||
__glutCurrentMenu->list = submenu;
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutChangeToMenuEntry(int num, const char *label, int value)
|
||||
{
|
||||
GLUTmenuItem *item;
|
||||
int i;
|
||||
|
||||
if (__glutMappedMenu) {
|
||||
menuModificationError();
|
||||
}
|
||||
i = __glutCurrentMenu->num;
|
||||
item = __glutCurrentMenu->list;
|
||||
while (item) {
|
||||
if (i == num) {
|
||||
if (item->isTrigger) {
|
||||
/* If changing a submenu trigger to a menu entry, we
|
||||
need to account for submenus. */
|
||||
item->menu->submenus--;
|
||||
/* Nuke the Win32 menu. */
|
||||
//todo
|
||||
// DestroyMenu((HMENU) item->win);
|
||||
}
|
||||
free(item->label);
|
||||
|
||||
item->label = strdup(label);
|
||||
if (!item->label)
|
||||
__glutFatalError("out of memory");
|
||||
item->isTrigger = FALSE;
|
||||
item->len = (int) strlen(label);
|
||||
item->value = value;
|
||||
item->unique = uniqueMenuHandler++;
|
||||
//todo
|
||||
// ModifyMenu((HMENU) __glutCurrentMenu->win, (UINT) i - 1,
|
||||
// MF_BYPOSITION | MFT_STRING, item->unique, label);
|
||||
|
||||
return;
|
||||
}
|
||||
i--;
|
||||
item = item->next;
|
||||
}
|
||||
__glutWarning("Current menu has no %d item.", num);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutChangeToSubMenu(int num, const char *label, int menu)
|
||||
{
|
||||
GLUTmenu *popupmenu;
|
||||
GLUTmenuItem *item;
|
||||
int i;
|
||||
|
||||
if (__glutMappedMenu) {
|
||||
menuModificationError();
|
||||
}
|
||||
i = __glutCurrentMenu->num;
|
||||
item = __glutCurrentMenu->list;
|
||||
while (item) {
|
||||
if (i == num) {
|
||||
if (!item->isTrigger) {
|
||||
/* If changing a menu entry to as submenu trigger, we
|
||||
need to account for submenus. */
|
||||
item->menu->submenus++;
|
||||
//todo
|
||||
// item->win = (HWND) CreatePopupMenu();
|
||||
}
|
||||
free(item->label);
|
||||
|
||||
item->label = strdup(label);
|
||||
if (!item->label)
|
||||
__glutFatalError("out of memory");
|
||||
item->isTrigger = TRUE;
|
||||
item->len = (int) strlen(label);
|
||||
item->value = menu - 1;
|
||||
item->unique = uniqueMenuHandler++;
|
||||
popupmenu = __glutGetMenuByNum(menu);
|
||||
if (popupmenu)
|
||||
item->win = popupmenu->win;
|
||||
//todo
|
||||
// ModifyMenu((HMENU) __glutCurrentMenu->win, (UINT) i - 1,
|
||||
// MF_BYPOSITION | MF_POPUP, (UINT) item->win, label);
|
||||
return;
|
||||
}
|
||||
i--;
|
||||
item = item->next;
|
||||
}
|
||||
__glutWarning("Current menu has no %d item.", num);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutRemoveMenuItem(int num)
|
||||
{
|
||||
GLUTmenuItem *item, **prev;
|
||||
int i;
|
||||
|
||||
if (__glutMappedMenu) {
|
||||
menuModificationError();
|
||||
}
|
||||
i = __glutCurrentMenu->num;
|
||||
prev = &__glutCurrentMenu->list;
|
||||
item = __glutCurrentMenu->list;
|
||||
while (item) {
|
||||
if (i == num) {
|
||||
/* Found the menu item in list to remove. */
|
||||
__glutCurrentMenu->num--;
|
||||
|
||||
/* Patch up menu's item list. */
|
||||
*prev = item->next;
|
||||
//todo
|
||||
// RemoveMenu((HMENU) __glutCurrentMenu->win, (UINT) i - 1, MF_BYPOSITION);
|
||||
|
||||
free(item->label);
|
||||
free(item);
|
||||
return;
|
||||
}
|
||||
i--;
|
||||
prev = &item->next;
|
||||
item = item->next;
|
||||
}
|
||||
__glutWarning("Current menu has no %d item.", num);
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutAttachMenu(int button)
|
||||
{
|
||||
if (__glutCurrentWindow == __glutGameModeWindow) {
|
||||
__glutWarning("cannot attach menus in game mode.");
|
||||
return;
|
||||
}
|
||||
if (__glutMappedMenu) {
|
||||
menuModificationError();
|
||||
}
|
||||
if (__glutCurrentWindow->menu[button] < 1) {
|
||||
__glutCurrentWindow->buttonUses++;
|
||||
}
|
||||
__glutCurrentWindow->menu[button] = __glutCurrentMenu->id + 1;
|
||||
}
|
||||
|
||||
void GLUTAPIENTRY
|
||||
glutDetachMenu(int button)
|
||||
{
|
||||
if (__glutMappedMenu) {
|
||||
menuModificationError();
|
||||
}
|
||||
if (__glutCurrentWindow->menu[button] > 0) {
|
||||
__glutCurrentWindow->buttonUses--;
|
||||
__glutCurrentWindow->menu[button] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Loading…
Reference in New Issue