diff options
Diffstat (limited to 'src/glut')
-rw-r--r-- | src/glut/beos/Makefile | 7 | ||||
-rw-r--r-- | src/glut/directfb/Makefile | 4 | ||||
-rw-r--r-- | src/glut/directfb/callback.c | 2 | ||||
-rw-r--r-- | src/glut/directfb/internal.h | 3 | ||||
-rw-r--r-- | src/glut/directfb/window.c | 22 | ||||
-rw-r--r-- | src/glut/fbdev/Makefile | 12 | ||||
-rw-r--r-- | src/glut/ggi/Makefile | 2 | ||||
-rw-r--r-- | src/glut/glx/Makefile | 34 | ||||
-rw-r--r-- | src/glut/glx/Makefile.mgw | 191 | ||||
-rw-r--r-- | src/glut/glx/SConscript | 3 | ||||
-rw-r--r-- | src/glut/glx/glut.def | 6 | ||||
-rw-r--r-- | src/glut/glx/glut.pc.in | 13 | ||||
-rw-r--r-- | src/glut/glx/glut_dstr.c | 1 | ||||
-rw-r--r-- | src/glut/glx/glut_event.c | 10 | ||||
-rw-r--r-- | src/glut/glx/glut_fcb.c (renamed from src/glut/glx/glut_fbc.c) | 50 | ||||
-rw-r--r-- | src/glut/glx/glut_init.c | 4 | ||||
-rw-r--r-- | src/glut/glx/glut_input.c | 2 | ||||
-rw-r--r-- | src/glut/glx/glut_ppm.c | 80 | ||||
-rw-r--r-- | src/glut/glx/glut_swap.c | 4 | ||||
-rw-r--r-- | src/glut/glx/glutint.h | 43 | ||||
-rw-r--r-- | src/glut/glx/win32_glx.c | 2 | ||||
-rw-r--r-- | src/glut/glx/win32_winproc.c | 4 | ||||
-rw-r--r-- | src/glut/mini/Makefile | 27 | ||||
-rw-r--r-- | src/glut/mini/glut.pc.in | 13 |
24 files changed, 442 insertions, 97 deletions
diff --git a/src/glut/beos/Makefile b/src/glut/beos/Makefile index a7ba512cb11..a9f8684c9bd 100644 --- a/src/glut/beos/Makefile +++ b/src/glut/beos/Makefile @@ -83,9 +83,10 @@ $(TOP)/$(LIB_DIR): # Make the library $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS) - @$(TOP)/bin/mklib -o $(GLUT_LIB) -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \ - -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) $(GLUT_LIB_DEPS) \ - $(OBJECTS) + @$(MKLIB) -o $(GLUT_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ + -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \ + -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \ + $(GLUT_LIB_DEPS) $(OBJECTS) clean: -rm -f *.o diff --git a/src/glut/directfb/Makefile b/src/glut/directfb/Makefile index e881b8aacdd..bf93d63e305 100644 --- a/src/glut/directfb/Makefile +++ b/src/glut/directfb/Makefile @@ -61,7 +61,7 @@ default: depend $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME) # Make the library $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS) - $(TOP)/bin/mklib -o $(GLUT_LIB) -linker '$(CC)' \ + $(MKLIB) -o $(GLUT_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \ $(GLUT_LIB_DEPS) -install $(TOP)/$(LIB_DIR) \ $(MKLIB_OPTIONS) $(OBJECTS) @@ -81,7 +81,7 @@ tags: # Remove .o and backup files clean: depend - -rm -f depend + -rm -f depend depend.bak -rm -f *.o *~ *.o *~ *.so libglut.so.3.7 include depend diff --git a/src/glut/directfb/callback.c b/src/glut/directfb/callback.c index 4f23441167a..7c9768aac0a 100644 --- a/src/glut/directfb/callback.c +++ b/src/glut/directfb/callback.c @@ -278,7 +278,7 @@ __glutGetTimeout( int *ret_msec ) gettimeofday( &now, NULL ); *ret_msec = (time->tv_sec - now.tv_sec) * 1000 + - (time->tv_usec - now.tv_usec + 500) / 1000; + (time->tv_usec - now.tv_usec + 999) / 1000; return GL_TRUE; } diff --git a/src/glut/directfb/internal.h b/src/glut/directfb/internal.h index 47311c9342b..55c4b5ce280 100644 --- a/src/glut/directfb/internal.h +++ b/src/glut/directfb/internal.h @@ -62,6 +62,9 @@ typedef struct __GlutWindow_s { IDirectFBSurface *surface; IDirectFBGL *gl; + /* display mode */ + GLenum mode; + /* cursor position in fullscreen mode */ int cx; int cy; diff --git a/src/glut/directfb/window.c b/src/glut/directfb/window.c index c8174d795e7..62cf8bb33e0 100644 --- a/src/glut/directfb/window.c +++ b/src/glut/directfb/window.c @@ -66,6 +66,9 @@ __glutCreateWindow( GLboolean fullscreen ) case 8: config.pixelformat = DSPF_RGB332; break; + case 12: + config.pixelformat = DSPF_ARGB4444; + break; case 15: config.pixelformat = DSPF_ARGB1555; break; @@ -109,7 +112,7 @@ __glutCreateWindow( GLboolean fullscreen ) if (joystick) joystick->AttachEventBuffer( joystick, events ); - new->visible = GL_TRUE; + new->visible = GL_TRUE; } else { DFBWindowDescription dsc; @@ -160,11 +163,12 @@ __glutCreateWindow( GLboolean fullscreen ) DWET_BUTTONDOWN | DWET_BUTTONUP | DWET_ENTER | DWET_LEAVE | DWET_MOTION | DWET_SIZE ); - new->req.flags |= WINDOW_REQUEST_SHOW; } + new->mode = g_display_mode; + new->reshape = GL_TRUE; new->visibility = GL_TRUE; new->redisplay = GL_TRUE; @@ -220,7 +224,8 @@ __glutHandleWindows( void ) __GlutWindow *cur = g_stack; while (cur) { - __GlutWindow *next = cur->next; + __GlutWindow *next = cur->next; + GLboolean displayed = GL_FALSE; if (cur->window && cur->req.flags) { if (cur == g_current) @@ -291,18 +296,29 @@ __glutHandleWindows( void ) cur->surface->GetSize( cur->surface, &w, &h ); __glutSetWindow( cur ); reshape_func( w, h ); + displayed = GL_TRUE; } if (cur->visibility && visibility_func) { g_idle = GL_FALSE; __glutSetWindow( cur ); visibility_func( cur->visible ? GLUT_VISIBLE : GLUT_NOT_VISIBLE ); + displayed = GL_TRUE; } if (cur->redisplay && display_func) { g_idle = GL_FALSE; __glutSetWindow( cur ); display_func(); + displayed = GL_TRUE; + } + + if (displayed && cur->window && cur->visible) { + if (!(cur->mode & GLUT_DOUBLE)) { + cur->gl->Unlock( cur->gl ); + cur->surface->Flip( cur->surface, NULL, 0 ); + cur->gl->Lock( cur->gl ); + } } cur->reshape = GL_FALSE; diff --git a/src/glut/fbdev/Makefile b/src/glut/fbdev/Makefile index b32b4141e8d..199d8c390a6 100644 --- a/src/glut/fbdev/Makefile +++ b/src/glut/fbdev/Makefile @@ -63,16 +63,16 @@ default: depend $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME) # Make the library $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS) - $(TOP)/bin/mklib -o $(GLUT_LIB) -linker '$(CC)' \ + $(MKLIB) -o $(GLUT_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \ $(GLUT_LIB_DEPS) -install $(TOP)/$(LIB_DIR) \ $(MKLIB_OPTIONS) $(OBJECTS) install: - $(INSTALL) -d $(INSTALL_DIR)/include/GL - $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR) - $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(INSTALL_DIR)/include/GL - $(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(INSTALL_DIR)/$(LIB_DIR) + $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/GL + $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) + $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(DESTDIR)$(INSTALL_INC_DIR)/GL + $(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(DESTDIR)$(INSTALL_LIB_DIR) # Run 'make -f Makefile.solo dep' to update the dependencies if you change # what's included by any source file. @@ -88,7 +88,7 @@ tags: # Remove .o and backup files clean: depend - -rm -f depend + -rm -f depend depend.bak -rm -f *.o *~ *.o *~ *.so libglut.so.3.7 include depend diff --git a/src/glut/ggi/Makefile b/src/glut/ggi/Makefile index 748c83c2286..c23dfcac105 100644 --- a/src/glut/ggi/Makefile +++ b/src/glut/ggi/Makefile @@ -32,7 +32,7 @@ default: $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME) # Make the library $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS) - $(TOP)/bin/mklib -o $(GLUT_LIB) -linker '$(CC)' \ + $(MKLIB) -o $(GLUT_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) \ -patch $(GLUT_TINY) $(MKLIB_OPTIONS) -install $(TOP)/$(LIB_DIR) \ $(GLUT_LIB_DEPS) $(OBJECTS) diff --git a/src/glut/glx/Makefile b/src/glut/glx/Makefile index 910c6fa28a4..9a975bbc60d 100644 --- a/src/glut/glx/Makefile +++ b/src/glut/glx/Makefile @@ -36,6 +36,7 @@ SOURCES = \ glut_dstr.c \ glut_event.c \ glut_ext.c \ + glut_fcb.c \ glut_fullscrn.c \ glut_gamemode.c \ glut_get.c \ @@ -55,6 +56,7 @@ SOURCES = \ glut_modifier.c \ glut_mroman.c \ glut_overlay.c \ + glut_ppm.c \ glut_roman.c \ glut_shapes.c \ glut_space.c \ @@ -90,25 +92,41 @@ default: $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME) # Make the library $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS) - $(TOP)/bin/mklib -o $(GLUT_LIB) -linker '$(CC)' \ + $(MKLIB) -o $(GLUT_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \ $(MKLIB_OPTIONS) -install $(TOP)/$(LIB_DIR) \ + -id $(INSTALL_LIB_DIR)/lib$(GLUT_LIB).$(GLUT_MAJOR).dylib \ $(GLUT_LIB_DEPS) $(OBJECTS) -install: - $(INSTALL) -d $(INSTALL_DIR)/include/GL - $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR) - $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(INSTALL_DIR)/include/GL - $(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(INSTALL_DIR)/$(LIB_DIR) +# glut pkgconfig file +pcedit = sed \ + -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \ + -e 's,@INSTALL_LIB_DIR@,$(INSTALL_LIB_DIR),' \ + -e 's,@INSTALL_INC_DIR@,$(INSTALL_INC_DIR),' \ + -e 's,@VERSION@,$(GLUT_MAJOR).$(GLUT_MINOR).$(GLUT_TINY),' \ + -e 's,@GLUT_PC_REQ_PRIV@,$(GLUT_PC_REQ_PRIV),' \ + -e 's,@GLUT_PC_LIB_PRIV@,$(GLUT_PC_LIB_PRIV),' \ + -e 's,@GLUT_PC_CFLAGS@,$(GLUT_PC_CFLAGS),' +glut.pc: glut.pc.in + $(pcedit) $< > $@ + +install: glut.pc + $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/GL + $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) + $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig + $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(DESTDIR)$(INSTALL_INC_DIR)/GL + $(INSTALL) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_GLOB) $(DESTDIR)$(INSTALL_LIB_DIR) + $(INSTALL) -m 644 glut.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig clean: -rm -f *.o *~ -rm -f *.lo -rm -f *.la + -rm -f *.pc -rm -rf .libs - -rm -rf depend depend.bak + -rm -f depend depend.bak depend: $(SOURCES) @@ -116,6 +134,6 @@ depend: $(SOURCES) @ rm -f depend @ touch depend @ $(MKDEP) $(MKDEP_OPTIONS) -I$(TOP)/include $(SOURCES) \ - > /dev/null + $(X11_INCLUDES) > /dev/null include depend diff --git a/src/glut/glx/Makefile.mgw b/src/glut/glx/Makefile.mgw new file mode 100644 index 00000000000..5e1fde03de2 --- /dev/null +++ b/src/glut/glx/Makefile.mgw @@ -0,0 +1,191 @@ +# Mesa 3-D graphics library +# Version: 5.1 +# +# Copyright (C) 1999-2003 Brian Paul All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +# MinGW core makefile v1.4 for Mesa +# +# Copyright (C) 2002 - Daniel Borca +# Email : [email protected] +# Web : http://www.geocities.com/dborca + +# MinGW core-glut makefile updated for Mesa 7.0 +# +# Updated : by Heromyth, on 2007-7-21 +# Email : [email protected] +# Bugs : 1) All the default settings work fine. But the setting X86=1 can't work. +# The others havn't been tested yet. +# 2) The generated DLLs are *not* compatible with the ones built +# with the other compilers like VC8, especially for GLUT. +# 3) Although more tests are needed, it can be used individually! + + +# +# Available options: +# +# Environment variables: +# CFLAGS +# +# GLIDE path to Glide3 SDK; used with FX. +# default = $(TOP)/glide3 +# FX=1 build for 3dfx Glide3. Note that this disables +# compilation of most WMesa code and requires fxMesa. +# As a consequence, you'll need the Win32 Glide3 +# library to build any application. +# default = no +# ICD=1 build the installable client driver interface +# (windows opengl driver interface) +# default = no +# X86=1 optimize for x86 (if possible, use MMX, SSE, 3DNow). +# default = no +# +# Targets: +# all: build GL +# clean: remove object files +# + + + +.PHONY: all clean +.INTERMEDIATE: x86/gen_matypes.exe +.SUFFIXES: .rc .res + +# Set this to the prefix of your build tools, i.e. mingw32- +TOOLS_PREFIX = mingw32- + +TOP = ../../.. + +LIBDIR = $(TOP)/lib + +LIB_NAME = glut32 + +DLL_EXT = .dll +IMP_EXT = .a +LIB_PRE = lib +STRIP = -s + +AR = ar +ARFLAGS = crus +DLLTOOL = dlltool + +GLUT_DLL = $(LIB_NAME)$(DLL_EXT) +GLUT_IMP = $(LIB_PRE)$(LIB_NAME)$(IMP_EXT) +GLUT_DEF = $(LIB_NAME).def + +LDLIBS = -L$(LIBDIR) -lwinmm -lgdi32 -luser32 -lopengl32 -lglu32 +LDFLAGS = $(STRIP) -shared -fPIC -Wl,--kill-at + +CFLAGS += -DBUILD_GLUT32 -DGLUT_BUILDING_LIB -DMESA -D_DLL +CFLAGS += -DNDEBUG -DLIBRARYBUILD -I$(TOP)/include + +CC = $(TOOLS_PREFIX)gcc +CXX = $(TOOLS_PREFIX)g++ +CXXFLAGS = $(CFLAGS) + +AR = ar +ARFLAGS = crus + +UNLINK = del $(subst /,\,$(1)) +ifneq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),) +UNLINK = $(RM) $(1) +endif +ifneq ($(wildcard $(addsuffix /rm,$(subst :, ,$(PATH)))),) +UNLINK = $(RM) $(1) +endif + +HDRS = glutint.h glutstroke.h glutbitmap.h glutwin32.h stroke.h win32_glx.h win32_x11.h + +SRCS = \ + glut_bitmap.c \ + glut_bwidth.c \ + glut_cindex.c \ + glut_cmap.c \ + glut_cursor.c \ + glut_dials.c \ + glut_dstr.c \ + glut_event.c \ + glut_ext.c \ + glut_fcb.c \ + glut_fullscrn.c \ + glut_gamemode.c \ + glut_get.c \ + glut_init.c \ + glut_input.c \ + glut_joy.c \ + glut_key.c \ + glut_keyctrl.c \ + glut_keyup.c \ + glut_mesa.c \ + glut_modifier.c \ + glut_overlay.c \ + glut_shapes.c \ + glut_space.c \ + glut_stroke.c \ + glut_swap.c \ + glut_swidth.c \ + glut_tablet.c \ + glut_teapot.c \ + glut_util.c \ + glut_vidresize.c \ + glut_warp.c \ + glut_win.c \ + glut_winmisc.c \ + win32_glx.c \ + win32_menu.c \ + win32_util.c \ + win32_winproc.c \ + win32_x11.c + + +SRCSSEMIGENS = \ + glut_8x13.c \ + glut_9x15.c \ + glut_hel10.c \ + glut_hel12.c \ + glut_hel18.c \ + glut_mroman.c \ + glut_roman.c \ + glut_tr10.c \ + glut_tr24.c + + + +SOURCES = $(SRCS) $(SRCSSEMIGENS) + +OBJECTS = $(addsuffix .o,$(basename $(SOURCES))) + +.c.o: + $(CC) -o $@ $(CFLAGS) -c $< +.cc.o: + $(CXX) -o $@ $(CXXFLAGS) -c $< + + +all: $(LIBDIR) $(LIBDIR)/$(GLUT_DLL) $(LIBDIR)/$(GLUT_IMP) + +$(LIBDIR): + mkdir -p $(LIBDIR) + +$(LIBDIR)/$(GLUT_DLL) $(LIBDIR)/$(GLUT_IMP): $(OBJECTS) + $(CXX) $(LDFLAGS) -o $(LIBDIR)/$(GLUT_DLL) $^ $(LDLIBS) + $(DLLTOOL) --as=as --dllname $(LIB_NAME) --output-def $(LIBDIR)/$(GLUT_DEF) $^ + $(DLLTOOL) --as=as -k --dllname $(LIB_NAME) --output-lib $(LIBDIR)/$(GLUT_IMP) --def $(LIBDIR)/$(GLUT_DEF) + +clean: + -$(call UNLINK,*.o)
\ No newline at end of file diff --git a/src/glut/glx/SConscript b/src/glut/glx/SConscript index 69f349ae2fc..938fec03df2 100644 --- a/src/glut/glx/SConscript +++ b/src/glut/glx/SConscript @@ -10,7 +10,6 @@ target = 'glut32' env.Replace(CPPDEFINES = [ 'BUILD_GLUT32', 'GLUT_BUILDING_LIB', - 'MESA', 'NDEBUG', 'GLUT_NO_WARNING_DISABLE', ]) @@ -37,7 +36,6 @@ sources = [ 'glut_dstr.c', 'glut_event.c', 'glut_ext.c', - 'glut_fbc.c', 'glut_fullscrn.c', 'glut_gamemode.c', 'glut_get.c', @@ -50,6 +48,7 @@ sources = [ 'glut_mesa.c', 'glut_modifier.c', 'glut_overlay.c', + 'glut_ppm.c', 'glut_shapes.c', 'glut_space.c', 'glut_stroke.c', diff --git a/src/glut/glx/glut.def b/src/glut/glx/glut.def index d5e0e0cf2af..90010815e49 100644 --- a/src/glut/glx/glut.def +++ b/src/glut/glx/glut.def @@ -1,9 +1,4 @@ -DESCRIPTION 'OpenGL Utility Toolkit for Win32' - -VERSION 3.7 - EXPORTS - glutAddMenuEntry glutAddSubMenu glutAttachMenu @@ -128,4 +123,3 @@ EXPORTS glutBitmapTimesRoman24 ; __glutSetFCB ; __glutGetFCB - diff --git a/src/glut/glx/glut.pc.in b/src/glut/glx/glut.pc.in new file mode 100644 index 00000000000..ae0689d7e81 --- /dev/null +++ b/src/glut/glx/glut.pc.in @@ -0,0 +1,13 @@ +prefix=@INSTALL_DIR@ +exec_prefix=${prefix} +libdir=@INSTALL_LIB_DIR@ +includedir=@INSTALL_INC_DIR@ + +Name: glut +Description: Mesa OpenGL Utility Toolkit library +Requires: gl glu +Requires.private: @GLUT_PC_REQ_PRIV@ +Version: @VERSION@ +Libs: -L${libdir} -lglut +Libs.private: @GLUT_PC_LIB_PRIV@ +Cflags: -I${includedir} @GLUT_PC_CFLAGS@ diff --git a/src/glut/glx/glut_dstr.c b/src/glut/glx/glut_dstr.c index ec9386f3e50..2513af45394 100644 --- a/src/glut/glx/glut_dstr.c +++ b/src/glut/glx/glut_dstr.c @@ -291,6 +291,7 @@ loadVisuals(int *nitems_return) fbmodes = (FrameBufferMode *) malloc(n * sizeof(FrameBufferMode)); if (fbmodes == NULL) { *nitems_return = -1; + free(vlist); return NULL; } for (i = 0; i < n; i++) { diff --git a/src/glut/glx/glut_event.c b/src/glut/glx/glut_event.c index 443f9a85740..d6d963896a6 100644 --- a/src/glut/glx/glut_event.c +++ b/src/glut/glx/glut_event.c @@ -24,7 +24,7 @@ # ifdef __sgi # include <bstring.h> /* prototype for bzero used by FD_ZERO */ # endif -# if (defined(SVR4) || defined(CRAY) || defined(AIXV3)) && !defined(FD_SETSIZE) +# if (defined(__FreeBSD__) || defined(SVR4) || defined(CRAY) || defined(AIXV3)) && !defined(FD_SETSIZE) # include <sys/select.h> /* select system call interface */ # ifdef luna # include <sysent.h> @@ -172,10 +172,14 @@ handleTimeouts(void) GETTIMEOFDAY(&now); while (IS_AT_OR_AFTER(__glutTimerList->timeout, now)) { timer = __glutTimerList; - __glutTimerList = timer->next; + /* call the timer function */ timer->func(timer->value); + /* remove from the linked list */ + __glutTimerList = timer->next; + /* put this timer on the "free" list */ timer->next = freeTimerList; freeTimerList = timer; + if (!__glutTimerList) break; } @@ -1339,9 +1343,7 @@ processWindowWorkList(GLUTwindow * window) } } -#ifndef _WIN32 static /* X11 implementations do not need this global. */ -#endif void __glutProcessWindowWorkLists(void) { diff --git a/src/glut/glx/glut_fbc.c b/src/glut/glx/glut_fcb.c index e93188b8622..c8a3422b360 100644 --- a/src/glut/glx/glut_fbc.c +++ b/src/glut/glx/glut_fcb.c @@ -19,7 +19,7 @@ /* Set a Fortran callback function. */ void APIENTRY -__glutSetFCB(int which, void *func) +__glutSetFCB(int which, GLUTproc func) { #ifdef SUPPORT_FORTRAN switch (which) { @@ -100,61 +100,61 @@ __glutSetFCB(int which, void *func) /* Get a Fortran callback function. */ -void* APIENTRY +GLUTproc APIENTRY __glutGetFCB(int which) { #ifdef SUPPORT_FORTRAN switch (which) { case GLUT_FCB_DISPLAY: - return (void *) __glutCurrentWindow->fdisplay; + return __glutCurrentWindow->fdisplay; case GLUT_FCB_RESHAPE: - return (void *) __glutCurrentWindow->freshape; + return __glutCurrentWindow->freshape; case GLUT_FCB_MOUSE: - return (void *) __glutCurrentWindow->fmouse; + return __glutCurrentWindow->fmouse; case GLUT_FCB_MOTION: - return (void *) __glutCurrentWindow->fmotion; + return __glutCurrentWindow->fmotion; case GLUT_FCB_PASSIVE: - return (void *) __glutCurrentWindow->fpassive; + return __glutCurrentWindow->fpassive; case GLUT_FCB_ENTRY: - return (void *) __glutCurrentWindow->fentry; + return __glutCurrentWindow->fentry; case GLUT_FCB_KEYBOARD: - return (void *) __glutCurrentWindow->fkeyboard; + return __glutCurrentWindow->fkeyboard; case GLUT_FCB_KEYBOARD_UP: - return (void *) __glutCurrentWindow->fkeyboardUp; + return __glutCurrentWindow->fkeyboardUp; case GLUT_FCB_WINDOW_STATUS: - return (void *) __glutCurrentWindow->fwindowStatus; + return __glutCurrentWindow->fwindowStatus; case GLUT_FCB_VISIBILITY: - return (void *) __glutCurrentWindow->fvisibility; + return __glutCurrentWindow->fvisibility; case GLUT_FCB_SPECIAL: - return (void *) __glutCurrentWindow->fspecial; + return __glutCurrentWindow->fspecial; case GLUT_FCB_SPECIAL_UP: - return (void *) __glutCurrentWindow->fspecialUp; + return __glutCurrentWindow->fspecialUp; case GLUT_FCB_BUTTON_BOX: - return (void *) __glutCurrentWindow->fbuttonBox; + return __glutCurrentWindow->fbuttonBox; case GLUT_FCB_DIALS: - return (void *) __glutCurrentWindow->fdials; + return __glutCurrentWindow->fdials; case GLUT_FCB_SPACE_MOTION: - return (void *) __glutCurrentWindow->fspaceMotion; + return __glutCurrentWindow->fspaceMotion; case GLUT_FCB_SPACE_ROTATE: - return (void *) __glutCurrentWindow->fspaceRotate; + return __glutCurrentWindow->fspaceRotate; case GLUT_FCB_SPACE_BUTTON: - return (void *) __glutCurrentWindow->fspaceButton; + return __glutCurrentWindow->fspaceButton; case GLUT_FCB_TABLET_MOTION: - return (void *) __glutCurrentWindow->ftabletMotion; + return __glutCurrentWindow->ftabletMotion; case GLUT_FCB_TABLET_BUTTON: - return (void *) __glutCurrentWindow->ftabletButton; + return __glutCurrentWindow->ftabletButton; case GLUT_FCB_JOYSTICK: #ifdef _WIN32 - return (void *) __glutCurrentWindow->fjoystick; + return __glutCurrentWindow->fjoystick; #else return NULL; #endif case GLUT_FCB_OVERLAY_DISPLAY: - return (void *) __glutCurrentWindow->overlay->fdisplay; + return __glutCurrentWindow->overlay->fdisplay; case GLUT_FCB_SELECT: - return (void *) __glutCurrentMenu->fselect; + return __glutCurrentMenu->fselect; case GLUT_FCB_TIMER: - return (void *) __glutTimerList->ffunc; + return __glutTimerList ? __glutTimerList->ffunc : NULL; default: return NULL; } diff --git a/src/glut/glx/glut_init.c b/src/glut/glx/glut_init.c index b1a42a328dc..78843e93bc2 100644 --- a/src/glut/glx/glut_init.c +++ b/src/glut/glx/glut_init.c @@ -51,6 +51,7 @@ int __glutInitX = -1, __glutInitY = -1; GLboolean __glutForceDirect = GL_FALSE, __glutTryDirect = GL_TRUE; Atom __glutWMDeleteWindow; +char *__glutPPMFile = NULL; /* *INDENT-ON* */ #ifdef _WIN32 @@ -341,6 +342,9 @@ glutInit(int *argcp, char **argv) __glutFPS = 5000; /* 5000 milliseconds */ } } + + /* check if GLUT_PPM_FILE env var is set */ + __glutPPMFile = getenv("GLUT_PPM_FILE"); } #ifdef _WIN32 diff --git a/src/glut/glx/glut_input.c b/src/glut/glx/glut_input.c index a76ff9a435e..7d2eda00f71 100644 --- a/src/glut/glx/glut_input.c +++ b/src/glut/glx/glut_input.c @@ -295,6 +295,7 @@ __glutProcessDeviceEvents(XEvent * event) static GLUTeventParser eventParser = {__glutProcessDeviceEvents, NULL}; +#if !defined(_WIN32) static void addDeviceEventParser(void) { @@ -305,6 +306,7 @@ addDeviceEventParser(void) been_here = True; __glutRegisterEventParser(&eventParser); } +#endif static int probeDevices(void) diff --git a/src/glut/glx/glut_ppm.c b/src/glut/glx/glut_ppm.c new file mode 100644 index 00000000000..49dca8532fd --- /dev/null +++ b/src/glut/glx/glut_ppm.c @@ -0,0 +1,80 @@ +/* + * PPM file output + * Brian Paul + * 8 Dec 2008 + */ + +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> +#include "glutint.h" + + +static void +write_ppm_file(const char *filename, const GLubyte *buffer, + int width, int height) +{ + const int binary = 1; + FILE *f = fopen( filename, "w" ); + if (f) { + const GLubyte *ptr = buffer; + int i, x, y; + if (binary) { + fprintf(f,"P6\n"); + fprintf(f,"# ppm-file created by GLUT\n"); + fprintf(f,"%i %i\n", width, height); + fprintf(f,"255\n"); + fclose(f); + f = fopen( filename, "ab" ); /* reopen in binary append mode */ + for (y = height - 1; y >= 0; y--) { + for (x = 0; x < width; x++) { + i = (y * width + x) * 4; + fputc(ptr[i], f); /* write red */ + fputc(ptr[i+1], f); /* write green */ + fputc(ptr[i+2], f); /* write blue */ + } + } + } + else { + /*ASCII*/ + int counter = 0; + fprintf(f,"P3\n"); + fprintf(f,"# ascii ppm file created by GLUT\n"); + fprintf(f,"%i %i\n", width, height); + fprintf(f,"255\n"); + for (y = height - 1; y >= 0; y--) { + for (x = 0; x < width; x++) { + i = (y * width + x) * 4; + fprintf(f, " %3d %3d %3d", ptr[i], ptr[i+1], ptr[i+2]); + counter++; + if (counter % 5 == 0) + fprintf(f, "\n"); + } + } + } + fclose(f); + } +} + + +/** + * Called from SwapBuffers if the GLUT_PPM_FILE env var is set. + */ +void __glutWritePPMFile(void) +{ + int w = glutGet(GLUT_WINDOW_WIDTH); + int h = glutGet(GLUT_WINDOW_HEIGHT); + GLubyte *buf; + + assert(__glutPPMFile); + + buf = (GLubyte *) malloc(w * h * 4); + if (buf) { + /* XXX save/restore pixel packing */ + glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, buf); + write_ppm_file(__glutPPMFile, buf, w, h); + free(buf); + } + + __glutPPMFile = NULL; /* only write one file */ +} diff --git a/src/glut/glx/glut_swap.c b/src/glut/glx/glut_swap.c index 4831b8eb351..07a2da88a2c 100644 --- a/src/glut/glx/glut_swap.c +++ b/src/glut/glx/glut_swap.c @@ -18,6 +18,10 @@ glutSwapBuffers(void) { GLUTwindow *window = __glutCurrentWindow; + if (__glutPPMFile) { + __glutWritePPMFile(); + } + if (window->renderWin == window->win) { if (__glutCurrentWindow->treatAsSingle) { /* Pretend the double buffered window is single buffered, diff --git a/src/glut/glx/glutint.h b/src/glut/glx/glutint.h index de506a5932d..ba30af60f0a 100644 --- a/src/glut/glx/glutint.h +++ b/src/glut/glx/glutint.h @@ -32,10 +32,6 @@ #include <GL/glut.h> -#if defined(MESA) && defined(_WIN32) && !defined(__CYGWIN32__) -#include <GL/mesa_wgl.h> -#endif - #ifndef _WIN32 /* added by BrianP: */ #ifndef APIENTRY @@ -48,24 +44,6 @@ /* GLUT_BUILDING_LIB is used by <GL/glut.h> to 1) not #pragma link with the GLUT library, and 2) avoid the Win32 atexit hack. */ -/* This must be done after <GL/gl.h> is included. MESA is defined - if the <GL/gl.h> is supplied by Brian Paul's Mesa library. */ -#if defined(MESA) && defined(_WIN32) -/* Mesa implements "wgl" versions of GDI entry points needed for - using OpenGL. Map these "wgl" versions to the GDI names via - macros. */ -#define ChoosePixelFormat wglChoosePixelFormat -#define DescribePixelFormat wglDescribePixelFormat -#define GetPixelFormat wglGetPixelFormat -#define SetPixelFormat wglSetPixelFormat -#define SwapBuffers wglSwapBuffers -#define GetCurrentContext wglGetCurrentContext -#define GetCurrentDC wglGetCurrentDC -#define MakeCurrent wglMakeCurrent -#define CreateContext wglCreateContext -#define DeleteContext wglDeleteContext -#endif /* MESA */ - #ifdef SUPPORT_FORTRAN #include <GL/glutf90.h> #endif @@ -572,27 +550,27 @@ typedef struct { #ifdef _WIN32 #define MAKE_CURRENT_LAYER(window) \ { \ - HGLRC currentContext = GetCurrentContext(); \ - HDC currentDc = GetCurrentDC(); \ + HGLRC currentContext = wglGetCurrentContext(); \ + HDC currentDc = wglGetCurrentDC(); \ \ if (currentContext != window->renderCtx \ || currentDc != window->renderDc) { \ - MakeCurrent(window->renderDc, window->renderCtx); \ + wglMakeCurrent(window->renderDc, window->renderCtx); \ } \ } #define MAKE_CURRENT_WINDOW(window) \ { \ - HGLRC currentContext = GetCurrentContext(); \ - HDC currentDc = GetCurrentDC(); \ + HGLRC currentContext = wglGetCurrentContext(); \ + HDC currentDc = wglGetCurrentDC(); \ \ if (currentContext != window->ctx || currentDc != window->hdc) { \ - MakeCurrent(window->hdc, window->ctx); \ + wglMakeCurrent(window->hdc, window->ctx); \ } \ } #define MAKE_CURRENT_OVERLAY(overlay) \ - MakeCurrent(overlay->hdc, overlay->ctx) + wglMakeCurrent(overlay->hdc, overlay->ctx) #define UNMAKE_CURRENT() \ - MakeCurrent(NULL, NULL) + wglMakeCurrent(NULL, NULL) #define SWAP_BUFFERS_WINDOW(window) \ SwapBuffers(window->hdc) #define SWAP_BUFFERS_LAYER(window) \ @@ -664,6 +642,7 @@ extern unsigned int __glutModifierMask; #ifdef _WIN32 extern void (__cdecl *__glutExitFunc)(int retval); #endif +extern char *__glutPPMFile; /* private variables from glut_menu.c */ extern GLUTmenuItem *__glutItemSelected; @@ -684,6 +663,9 @@ extern void __glutFreeOverlay(GLUToverlay * overlay); extern XVisualInfo *__glutDetermineWindowVisual(Bool * treatAsSingle, Bool * visAlloced, void **fbc); +/* private variables from glut_ppm.c */ +extern void __glutWritePPMFile(void); + /* private variables from glut_mesa.c */ extern int __glutMesaSwapHackSupport; @@ -812,4 +794,5 @@ extern LONG WINAPI __glutWindowProc(HWND win, UINT msg, WPARAM w, LPARAM l); extern HDC XHDC; #endif + #endif /* __glutint_h__ */ diff --git a/src/glut/glx/win32_glx.c b/src/glut/glx/win32_glx.c index ecfff44b930..3522e606ec8 100644 --- a/src/glut/glx/win32_glx.c +++ b/src/glut/glx/win32_glx.c @@ -22,7 +22,7 @@ glXCreateContext(Display * display, XVisualInfo * visinfo, routine. */ HGLRC context; - context = CreateContext(XHDC); + context = wglCreateContext(XHDC); #if 0 /* XXX GLUT doesn't support it now, so don't worry about display list diff --git a/src/glut/glx/win32_winproc.c b/src/glut/glx/win32_winproc.c index e1fc785ebb7..4a9dc3781c2 100644 --- a/src/glut/glx/win32_winproc.c +++ b/src/glut/glx/win32_winproc.c @@ -20,10 +20,10 @@ extern unsigned __glutMenuButton; extern GLUTidleCB __glutIdleFunc; extern GLUTtimer *__glutTimerList; -extern GLUTmenuItem *__glutGetUniqueMenuItem(GLUTmenu * menu, int unique); +extern GLUTmenuItem *__glutGetUniqueMenuItem(GLUTmenu * menu, UINT unique); static HMENU __glutHMenu; -void +static void updateWindowState(GLUTwindow *window, int visState) { GLUTwindow* child; diff --git a/src/glut/mini/Makefile b/src/glut/mini/Makefile index 980306d0e28..841a473f891 100644 --- a/src/glut/mini/Makefile +++ b/src/glut/mini/Makefile @@ -55,7 +55,7 @@ default: depend $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME) # Make the library $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS) - $(TOP)/bin/mklib -o $(GLUT_LIB) -linker '$(CC)' \ + $(MKLIB) -o $(GLUT_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \ $(GLUT_LIB_DEPS) -install $(TOP)/$(LIB_DIR) \ $(MKLIB_OPTIONS) $(OBJECTS) @@ -73,9 +73,30 @@ tags: etags `find . -name \*.[ch]` `find ../include` +# glut pkgconfig file +pcedit = sed \ + -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \ + -e 's,@INSTALL_LIB_DIR@,$(INSTALL_LIB_DIR),' \ + -e 's,@INSTALL_INC_DIR@,$(INSTALL_INC_DIR),' \ + -e 's,@VERSION@,$(GLUT_MAJOR).$(GLUT_MINOR).$(GLUT_TINY),' \ + -e 's,@GLUT_PC_REQ_PRIV@,$(GLUT_PC_REQ_PRIV),' \ + -e 's,@GLUT_PC_LIB_PRIV@,$(GLUT_PC_LIB_PRIV),' \ + -e 's,@GLUT_PC_CFLAGS@,$(GLUT_PC_CFLAGS),' +glut.pc: glut.pc.in + $(pcedit) $< > $@ + +install: glut.pc + $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/GL + $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) + $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig + $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(DESTDIR)$(INSTALL_INC_DIR)/GL + $(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(DESTDIR)$(INSTALL_LIB_DIR) + $(INSTALL) -m 644 glut.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig + + # Remove .o and backup files clean: depend - -rm -f depend - -rm -f *.o *~ *.o *~ *.so libglut.so.3.7 + -rm -f depend depend.bak + -rm -f *.o *~ *.o *~ *.so *.pc libglut.so.3.7 include depend diff --git a/src/glut/mini/glut.pc.in b/src/glut/mini/glut.pc.in new file mode 100644 index 00000000000..ae0689d7e81 --- /dev/null +++ b/src/glut/mini/glut.pc.in @@ -0,0 +1,13 @@ +prefix=@INSTALL_DIR@ +exec_prefix=${prefix} +libdir=@INSTALL_LIB_DIR@ +includedir=@INSTALL_INC_DIR@ + +Name: glut +Description: Mesa OpenGL Utility Toolkit library +Requires: gl glu +Requires.private: @GLUT_PC_REQ_PRIV@ +Version: @VERSION@ +Libs: -L${libdir} -lglut +Libs.private: @GLUT_PC_LIB_PRIV@ +Cflags: -I${includedir} @GLUT_PC_CFLAGS@ |