summaryrefslogtreecommitdiff
path: root/src/glut/glx
diff options
context:
space:
mode:
Diffstat (limited to 'src/glut/glx')
-rw-r--r--src/glut/glx/Makefile34
-rw-r--r--src/glut/glx/Makefile.mgw191
-rw-r--r--src/glut/glx/SConscript3
-rw-r--r--src/glut/glx/glut.def6
-rw-r--r--src/glut/glx/glut.pc.in13
-rw-r--r--src/glut/glx/glut_dstr.c1
-rw-r--r--src/glut/glx/glut_event.c10
-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.c4
-rw-r--r--src/glut/glx/glut_input.c2
-rw-r--r--src/glut/glx/glut_ppm.c80
-rw-r--r--src/glut/glx/glut_swap.c4
-rw-r--r--src/glut/glx/glutint.h43
-rw-r--r--src/glut/glx/win32_glx.c2
-rw-r--r--src/glut/glx/win32_winproc.c4
15 files changed, 369 insertions, 78 deletions
diff --git a/src/glut/glx/Makefile b/src/glut/glx/Makefile
index 910c6fa28a..9a975bbc60 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 0000000000..5e1fde03de
--- /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 : dborca@users.sourceforge.net
+# Web : http://www.geocities.com/dborca
+
+# MinGW core-glut makefile updated for Mesa 7.0
+#
+# Updated : by Heromyth, on 2007-7-21
+# Email : zxpmyth@yahoo.com.cn
+# 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 69f349ae2f..938fec03df 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 d5e0e0cf2a..90010815e4 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 0000000000..ae0689d7e8
--- /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 ec9386f3e5..2513af4539 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 443f9a8574..d6d963896a 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 e93188b862..c8a3422b36 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 b1a42a328d..78843e93bc 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 a76ff9a435..7d2eda00f7 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 0000000000..49dca8532f
--- /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 4831b8eb35..07a2da88a2 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 de506a5932..ba30af60f0 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 ecfff44b93..3522e606ec 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 e1fc785ebb..4a9dc3781c 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;