3D Canvas

Check-in [80db3dfd6f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixes to the build system to avoid including entire C files into the middle of generic/c3dmain.c

Now TEA understands how to add the appropriate platform buildfile to Make. Each of the platform C files has been modified to compile independently. Added a functional API for platform call-outs to c3d.h

Replaced a pile of K&R declarations with ANSI ones

Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:80db3dfd6fb45963120dbd97f3aa521d76fa7c56
User & Date: hypnotoad 2016-10-06 22:06:48
Context
2016-10-10
18:05
Accepting several fixes from the Androwish project. Bumping version to 1.2.4

Reverted to TEA 3.9

Several build improvements for SDL

Fixes 32 bpp memory mapping in X11 check-in: bc31d403e7 user: hypnotoad tags: trunk

2016-10-06
22:06
Fixes to the build system to avoid including entire C files into the middle of generic/c3dmain.c

Now TEA understands how to add the appropriate platform buildfile to Make. Each of the platform C files has been modified to compile independently. Added a functional API for platform call-outs to c3d.h

Replaced a pile of K&R declarations with ANSI ones check-in: 80db3dfd6f user: hypnotoad tags: trunk

21:02
Adding local platform source directories check-in: 0707d48d3f user: hypnotoad tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Makefile.in.

310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# 	$(COMPILE) -c `@CYGPATH@ $(srcdir)/generic/sample.c` -o $@
#
# Setting the VPATH variable to a list of paths will cause the makefile
# to look into these paths when resolving .c to .obj dependencies.
# As necessary, add $(srcdir):$(srcdir)/compat:....
#========================================================================

VPATH = $(srcdir):$(srcdir)/generic:$(srcdir)/unix:$(srcdir)/win

.c.@OBJEXT@:
	$(COMPILE) -c `@CYGPATH@ $<` -o $@

#========================================================================
# Distribution creation
# You may need to tweak this target to make it work correctly.







|







310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# 	$(COMPILE) -c `@CYGPATH@ $(srcdir)/generic/sample.c` -o $@
#
# Setting the VPATH variable to a list of paths will cause the makefile
# to look into these paths when resolving .c to .obj dependencies.
# As necessary, add $(srcdir):$(srcdir)/compat:....
#========================================================================

VPATH = $(srcdir):$(srcdir)/generic:$(srcdir)/unix:$(srcdir)/win:$(srcdir)/macosx:$(srcdir)/sdl

.c.@OBJEXT@:
	$(COMPILE) -c `@CYGPATH@ $<` -o $@

#========================================================================
# Distribution creation
# You may need to tweak this target to make it work correctly.

Changes to configure.

6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147



































6148
6149
6150
6151
6152
6153
6154

6155
6156
6157
6158



































6159
6160
6161
6162
6163
6164
6165
....
6168
6169
6170
6171
6172
6173
6174
6175

6176
6177
6178
6179



































6180
6181
6182
6183
6184
6185
6186
....
6200
6201
6202
6203
6204
6205
6206

6207

6208
6209
6210
6211
6212
6213
6214
6215
6216
6217

































6218
6219
6220
6221
6222
6223
6224
	fi
	PKG_LIBS="$PKG_LIBS $i"
    done


    # Ensure no empty if clauses
    :
    #TEA_ADD_SOURCES([win/winFile.c])

    vars="-I\"$(${CYGPATH} ${srcdir}/win)\""
    for i in $vars; do
	PKG_INCLUDES="$PKG_INCLUDES $i"
    done





































    CAN3D_WINDOWINGSYSTEM=CAN3D_WGL

elif test "${TEA_WINDOWINGSYSTEM}" = "aqua" ; then
    #TEA_ADD_LIBS([-framework AGL -framework OpenGL -framework ApplicationServices -framework CoreFoundation -framework Cocoa])


    vars="-I\"${srcdir}/macosx)\""
    for i in $vars; do
	PKG_INCLUDES="$PKG_INCLUDES $i"
    done






































    vars="-framework OpenGL -framework ApplicationServices -framework CoreFoundation -framework Cocoa"
    for i in $vars; do
	if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then
	    # Convert foo.lib to -lfoo for GCC.  No-op if not *.lib
................................................................................
	PKG_LIBS="$PKG_LIBS $i"
    done


    CAN3D_WINDOWINGSYSTEM=CAN3D_AGL

elif test "${TEA_WINDOWINGSYSTEM}" = "sdl" ; then


    vars="-I\"${srcdir}/sdl)\""
    for i in $vars; do
	PKG_INCLUDES="$PKG_INCLUDES $i"
    done






































    vars="-lGL"
    for i in $vars; do
	if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then
	    # Convert foo.lib to -lfoo for GCC.  No-op if not *.lib
................................................................................
	    # Convert foo.lib to -lfoo for GCC.  No-op if not *.lib
	    i=`echo "$i" | sed -e 's/^\([^-].*\)\.lib$/-l\1/i'`
	fi
	PKG_LIBS="$PKG_LIBS $i"
    done





    vars="-I\"${srcdir}/unix)\""
    for i in $vars; do
	PKG_INCLUDES="$PKG_INCLUDES $i"
    done


    # Ensure no empty else clauses
    :
    #TEA_ADD_SOURCES([unix/unixFile.c])
    #TEA_ADD_LIBS([-lsuperfly])

































    CAN3D_WINDOWINGSYSTEM=CAN3D_X11

fi


#--------------------------------------------------------------------
# __CHANGE__







<

|



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






|
>
|



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|
>
|



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
|
>
|





<
|
<
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







6135
6136
6137
6138
6139
6140
6141

6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
....
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
....
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321

6322

6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
	fi
	PKG_LIBS="$PKG_LIBS $i"
    done


    # Ensure no empty if clauses
    :


    vars="-I\"$(${CYGPATH} ${srcdir}/generic)\""
    for i in $vars; do
	PKG_INCLUDES="$PKG_INCLUDES $i"
    done



    vars="win/c3dWinMain.c"
    for i in $vars; do
	case $i in
	    \$*)
		# allow $-var names
		PKG_SOURCES="$PKG_SOURCES $i"
		PKG_OBJECTS="$PKG_OBJECTS $i"
		;;
	    *)
		# check for existence - allows for generic/win/unix VPATH
		# To add more dirs here (like 'src'), you have to update VPATH
		# in Makefile.in as well
		if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \
		    -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \
		    -a ! -f "${srcdir}/macosx/$i" \
		    ; then
		    as_fn_error $? "could not find source file '$i'" "$LINENO" 5
		fi
		PKG_SOURCES="$PKG_SOURCES $i"
		# this assumes it is in a VPATH dir
		i=`basename $i`
		# handle user calling this before or after TEA_SETUP_COMPILER
		if test x"${OBJEXT}" != x ; then
		    j="`echo $i | sed -e 's/\.[^.]*$//'`.${OBJEXT}"
		else
		    j="`echo $i | sed -e 's/\.[^.]*$//'`.\${OBJEXT}"
		fi
		PKG_OBJECTS="$PKG_OBJECTS $j"
		;;
	esac
    done



    CAN3D_WINDOWINGSYSTEM=CAN3D_WGL

elif test "${TEA_WINDOWINGSYSTEM}" = "aqua" ; then
    #TEA_ADD_LIBS([-framework AGL -framework OpenGL -framework ApplicationServices -framework CoreFoundation -framework Cocoa])
    :

    vars="-I\"${srcdir}/generic\""
    for i in $vars; do
	PKG_INCLUDES="$PKG_INCLUDES $i"
    done



    vars="macosx/c3dCocoaMain.c"
    for i in $vars; do
	case $i in
	    \$*)
		# allow $-var names
		PKG_SOURCES="$PKG_SOURCES $i"
		PKG_OBJECTS="$PKG_OBJECTS $i"
		;;
	    *)
		# check for existence - allows for generic/win/unix VPATH
		# To add more dirs here (like 'src'), you have to update VPATH
		# in Makefile.in as well
		if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \
		    -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \
		    -a ! -f "${srcdir}/macosx/$i" \
		    ; then
		    as_fn_error $? "could not find source file '$i'" "$LINENO" 5
		fi
		PKG_SOURCES="$PKG_SOURCES $i"
		# this assumes it is in a VPATH dir
		i=`basename $i`
		# handle user calling this before or after TEA_SETUP_COMPILER
		if test x"${OBJEXT}" != x ; then
		    j="`echo $i | sed -e 's/\.[^.]*$//'`.${OBJEXT}"
		else
		    j="`echo $i | sed -e 's/\.[^.]*$//'`.\${OBJEXT}"
		fi
		PKG_OBJECTS="$PKG_OBJECTS $j"
		;;
	esac
    done




    vars="-framework OpenGL -framework ApplicationServices -framework CoreFoundation -framework Cocoa"
    for i in $vars; do
	if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then
	    # Convert foo.lib to -lfoo for GCC.  No-op if not *.lib
................................................................................
	PKG_LIBS="$PKG_LIBS $i"
    done


    CAN3D_WINDOWINGSYSTEM=CAN3D_AGL

elif test "${TEA_WINDOWINGSYSTEM}" = "sdl" ; then
    :

    vars="-I\"${srcdir}/generic\""
    for i in $vars; do
	PKG_INCLUDES="$PKG_INCLUDES $i"
    done



    vars="sdl/c3dSLDMain.c"
    for i in $vars; do
	case $i in
	    \$*)
		# allow $-var names
		PKG_SOURCES="$PKG_SOURCES $i"
		PKG_OBJECTS="$PKG_OBJECTS $i"
		;;
	    *)
		# check for existence - allows for generic/win/unix VPATH
		# To add more dirs here (like 'src'), you have to update VPATH
		# in Makefile.in as well
		if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \
		    -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \
		    -a ! -f "${srcdir}/macosx/$i" \
		    ; then
		    as_fn_error $? "could not find source file '$i'" "$LINENO" 5
		fi
		PKG_SOURCES="$PKG_SOURCES $i"
		# this assumes it is in a VPATH dir
		i=`basename $i`
		# handle user calling this before or after TEA_SETUP_COMPILER
		if test x"${OBJEXT}" != x ; then
		    j="`echo $i | sed -e 's/\.[^.]*$//'`.${OBJEXT}"
		else
		    j="`echo $i | sed -e 's/\.[^.]*$//'`.\${OBJEXT}"
		fi
		PKG_OBJECTS="$PKG_OBJECTS $j"
		;;
	esac
    done




    vars="-lGL"
    for i in $vars; do
	if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then
	    # Convert foo.lib to -lfoo for GCC.  No-op if not *.lib
................................................................................
	    # Convert foo.lib to -lfoo for GCC.  No-op if not *.lib
	    i=`echo "$i" | sed -e 's/^\([^-].*\)\.lib$/-l\1/i'`
	fi
	PKG_LIBS="$PKG_LIBS $i"
    done


    # Ensure no empty else clauses
    :

    vars="-I\"${srcdir}/generic\""
    for i in $vars; do
	PKG_INCLUDES="$PKG_INCLUDES $i"
    done





    vars="unix/c3dX11Main.c"
    for i in $vars; do
	case $i in
	    \$*)
		# allow $-var names
		PKG_SOURCES="$PKG_SOURCES $i"
		PKG_OBJECTS="$PKG_OBJECTS $i"
		;;
	    *)
		# check for existence - allows for generic/win/unix VPATH
		# To add more dirs here (like 'src'), you have to update VPATH
		# in Makefile.in as well
		if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \
		    -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \
		    -a ! -f "${srcdir}/macosx/$i" \
		    ; then
		    as_fn_error $? "could not find source file '$i'" "$LINENO" 5
		fi
		PKG_SOURCES="$PKG_SOURCES $i"
		# this assumes it is in a VPATH dir
		i=`basename $i`
		# handle user calling this before or after TEA_SETUP_COMPILER
		if test x"${OBJEXT}" != x ; then
		    j="`echo $i | sed -e 's/\.[^.]*$//'`.${OBJEXT}"
		else
		    j="`echo $i | sed -e 's/\.[^.]*$//'`.\${OBJEXT}"
		fi
		PKG_OBJECTS="$PKG_OBJECTS $j"
		;;
	esac
    done



    CAN3D_WINDOWINGSYSTEM=CAN3D_X11

fi


#--------------------------------------------------------------------
# __CHANGE__

Changes to configure.in.

112
113
114
115
116
117
118
119
120
121
122
123

124

125
126
127

128

129
130
131
132
133
134
135

136
137
138
139
140
141
142
143
144

#CLEANFILES="$CLEANFILES pkgIndex.tcl"
if test "${TEA_PLATFORM}" = "windows" ; then
    CLEANFILES="$CLEANFILES *.lib *.dll *.exp *.ilk *.pdb vc*.pch"
    TEA_ADD_LIBS([opengl32.lib glu32.lib gdi32.lib user32.lib shell32.lib])
    # Ensure no empty if clauses
    :
    #TEA_ADD_SOURCES([win/winFile.c])
    TEA_ADD_INCLUDES([-I\"$(${CYGPATH} ${srcdir}/win)\"])
    AC_SUBST(CAN3D_WINDOWINGSYSTEM,CAN3D_WGL)
elif test "${TEA_WINDOWINGSYSTEM}" = "aqua" ; then
    #TEA_ADD_LIBS([-framework AGL -framework OpenGL -framework ApplicationServices -framework CoreFoundation -framework Cocoa])

    TEA_ADD_INCLUDES([-I\"${srcdir}/macosx)\"])

    TEA_ADD_LIBS([-framework OpenGL -framework ApplicationServices -framework CoreFoundation -framework Cocoa])
    AC_SUBST(CAN3D_WINDOWINGSYSTEM,CAN3D_AGL)
elif test "${TEA_WINDOWINGSYSTEM}" = "sdl" ; then

    TEA_ADD_INCLUDES([-I\"${srcdir}/sdl)\"])

    TEA_ADD_LIBS([-lGL])
    AC_SUBST(CAN3D_WINDOWINGSYSTEM,CAN3D_SDL)
else
    TEA_ADD_LIBS([-lGL -lGLU])
    TEA_ADD_INCLUDES([-I\"${srcdir}/unix)\"])
    # Ensure no empty else clauses
    :

    #TEA_ADD_SOURCES([unix/unixFile.c])
    #TEA_ADD_LIBS([-lsuperfly])
    AC_SUBST(CAN3D_WINDOWINGSYSTEM,CAN3D_X11)
fi
AC_SUBST(TEA_WINDOWINGSYSTEM)

#--------------------------------------------------------------------
# __CHANGE__
# Choose which headers you need.  Extension authors should try very







|
|



>
|
>



>
|
>




<


>
|
<







112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136

137
138
139
140

141
142
143
144
145
146
147

#CLEANFILES="$CLEANFILES pkgIndex.tcl"
if test "${TEA_PLATFORM}" = "windows" ; then
    CLEANFILES="$CLEANFILES *.lib *.dll *.exp *.ilk *.pdb vc*.pch"
    TEA_ADD_LIBS([opengl32.lib glu32.lib gdi32.lib user32.lib shell32.lib])
    # Ensure no empty if clauses
    :
    TEA_ADD_INCLUDES([-I\"$(${CYGPATH} ${srcdir}/generic)\"])
    TEA_ADD_SOURCES([win/c3dWinMain.c])
    AC_SUBST(CAN3D_WINDOWINGSYSTEM,CAN3D_WGL)
elif test "${TEA_WINDOWINGSYSTEM}" = "aqua" ; then
    #TEA_ADD_LIBS([-framework AGL -framework OpenGL -framework ApplicationServices -framework CoreFoundation -framework Cocoa])
    :
    TEA_ADD_INCLUDES([-I\"${srcdir}/generic\"])
    TEA_ADD_SOURCES([macosx/c3dCocoaMain.c])
    TEA_ADD_LIBS([-framework OpenGL -framework ApplicationServices -framework CoreFoundation -framework Cocoa])
    AC_SUBST(CAN3D_WINDOWINGSYSTEM,CAN3D_AGL)
elif test "${TEA_WINDOWINGSYSTEM}" = "sdl" ; then
    :
    TEA_ADD_INCLUDES([-I\"${srcdir}/generic\"])
    TEA_ADD_SOURCES([sdl/c3dSLDMain.c])
    TEA_ADD_LIBS([-lGL])
    AC_SUBST(CAN3D_WINDOWINGSYSTEM,CAN3D_SDL)
else
    TEA_ADD_LIBS([-lGL -lGLU])

    # Ensure no empty else clauses
    :
    TEA_ADD_INCLUDES([-I\"${srcdir}/generic\"])
    TEA_ADD_SOURCES([unix/c3dX11Main.c])

    AC_SUBST(CAN3D_WINDOWINGSYSTEM,CAN3D_X11)
fi
AC_SUBST(TEA_WINDOWINGSYSTEM)

#--------------------------------------------------------------------
# __CHANGE__
# Choose which headers you need.  Extension authors should try very

Changes to generic/c3d.h.

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
...
562
563
564
565
566
567
568



































569
570
571
#endif

#include <GL/gl.h>

#endif

#define CANVAS3D_VERSION "1.2.2"

/* Structures available to all source code files. */
typedef struct C3dWidget C3dWidget;
typedef struct C3dItem C3dItem;
typedef struct C3dWidgetOptions C3dWidgetOptions;
typedef struct C3dVertex C3dVertex;
typedef struct C3dItemType C3dItemType;
typedef struct C3dColor C3dColor;
................................................................................
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif




































#endif









<







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



67
68
69
70
71
72
73

74
75
76
77
78
79
80
...
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
#endif

#include <GL/gl.h>

#endif

#define CANVAS3D_VERSION "1.2.2"

/* Structures available to all source code files. */
typedef struct C3dWidget C3dWidget;
typedef struct C3dItem C3dItem;
typedef struct C3dWidgetOptions C3dWidgetOptions;
typedef struct C3dVertex C3dVertex;
typedef struct C3dItemType C3dItemType;
typedef struct C3dColor C3dColor;
................................................................................
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif

/* Platform specific hooks */

/*
** Tk_ClassProcs C3dCanvasProcs -> Array of functions exposed directly to TK
** C3d_Native_Select3dContext -> Function to select a 3d window for GL rendering
** C3d_Native_ResizeContext -> Function to syncronize the size of the GL windows with the Tk Window
** C3d_Native_DeleteContext -> Function to delete a GL context after TK destroyed
** C3d_Native_CreateCanvas3d -> Function to produce an openGL context and canvas
** C3d_Native_Pixmap3dToPixmap -> Function to Copy from C3dPixmap.pixmap to C3dPixmap.pixmap3d
** C3d_Native_PixmapToPixmap3d -> Function to Copy from C3dPixmap.pixmap3d to C3dPixmap.pixmap
** C3d_Native_PixmapToWindow -> Copy pixmap to main window
** C3d_Native_EventProc -> Function to handle <Expose> events
*/extern const Tk_ClassProcs C3dCanvasProcs;

void C3d_Native_EventProc(ClientData clientData, XEvent *eventPtr);
void C3d_Native_Select3dContext(C3dWidget *pCanvas);
void C3d_Native_ResizeContext(C3dWidget *pCanvas,int w,int h);
void C3d_Native_DeleteContext(C3dWidget *pCanvas);
void C3d_Native_FreePixMaps(C3dWidget *pCanvas);
Window C3d_Native_CreateCanvas3d(Tk_Window tkwin, Window parent, ClientData clientData);
void C3d_Native_Select3dContext(C3dWidget *pCanvas);
void C3d_Native_Release3dContext(C3dWidget *pCanvas);
void C3d_Native_Pixmap3dToPixmap(C3dWidget *pCanvas);
void C3d_Native_PixmapToPixmap3d(C3dWidget *pCanvas);
void C3d_Native_PixmapToWindow(C3dWidget *pCanvas);
int C3d_Native_Init(Tcl_Interp *interp);

void C3d_Canvas_WorldChanged(ClientData clientData);

/*
 * Possible values for the C3dWidgetOptions.saveunder variable:
 */
#define SAVEUNDER_NONE 0
#define SAVEUNDER_3D   1
#define SAVEUNDER_ALL  2
#endif


Changes to generic/c3dmain.c.

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

67
68
69
70
71
72
73
...
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
...
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
...
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
static void C3d_Canvas_EventProc(ClientData clientData, XEvent *eventPtr);
static void C3d_Canvas_Delete(ClientData clientData);
#ifdef C3dFree
static void C3dFreeFunc(ClientData clientData);
#endif

static void C3d_Canvas_DrawWhenIdle(ClientData clientData);
static void C3d_Canvas_WorldChanged(ClientData clientData);

static void C3d_Native_EventProc(ClientData clientData, XEvent *eventPtr);
static void C3d_Native_Select3dContext(C3dWidget *pCanvas);
static void C3d_Native_ResizeContext(C3dWidget *pCanvas,int w,int h);
static void C3d_Native_DeleteContext(C3dWidget *pCanvas);
static void C3d_Native_FreePixMaps(C3dWidget *pCanvas);
static Window C3d_Native_CreateCanvas3d(Tk_Window tkwin, Window parent, ClientData clientData);
static void C3d_Native_Select3dContext(C3dWidget *pCanvas);
static void C3d_Native_Release3dContext(C3dWidget *pCanvas);
static void C3d_Native_Pixmap3dToPixmap(C3dWidget *pCanvas);
static void C3d_Native_PixmapToPixmap3d(C3dWidget *pCanvas);
static void C3d_Native_PixmapToWindow(C3dWidget *pCanvas);
static int C3d_Native_Init(Tcl_Interp *interp);

/*
 *---------------------------------------------------------------------------
 *
 * vertexOptionSet --
 *
 *     The functions vertexOptionSet(), vertexOptionGet(),
 *     vertexOptionFree() and vertexOptionRestore() implement a Tk option
................................................................................
    vertexOptionFree,
    0
};

/*
 * Possible values for the C3dWidgetOptions.saveunder variable:
 */
#define SAVEUNDER_NONE 0
#define SAVEUNDER_3D   1
#define SAVEUNDER_ALL  2
static const char * SaveunderStrings[] = {"none", "3d", "all", 0};

/*
 * The option_spec array defines the widget options accepted by the
 * [$win configure], [$win cget] and [canvas3d] commands. To neaten things
 * up, Tk_OptionSpec instances are populated using the WIDGET_OPTION macro.
 */
................................................................................
** C3d_Native_ResizeContext -> Function to syncronize the size of the GL windows with the Tk Window
** C3d_Native_DeleteContext -> Function to delete a GL context after TK destroyed
** C3d_Native_CreateCanvas3d -> Function to produce an openGL context and canvas
** C3d_Native_Pixmap3dToPixmap -> Function to Copy from C3dPixmap.pixmap to C3dPixmap.pixmap3d
** C3d_Native_PixmapToPixmap3d -> Function to Copy from C3dPixmap.pixmap3d to C3dPixmap.pixmap
** C3d_Native_PixmapToWindow -> Copy pixmap to main window
** C3d_Native_EventProc -> Function to handle <Expose> events
**
*/

#if defined(CAN3D_WGL)
# include "c3dWinMain.c"
#elif defined(CAN3D_NSOPENGL)
# include "c3dCocoaMain.c"
#elif defined(CAN3D_AGL)
# include "c3dCarbonMain.c"
#elif defined(CAN3D_SDL)
# include "c3dSDLMain.c"
#else
# include "c3dX11Main.c"
#endif

/*
 *---------------------------------------------------------------------------
 *
 * C3d_Canvas_DrawNow --
 *
 *     Redraw the entire widget. This function also resizes the X-window if
 *     the size of the Tk window has changed. This function is usually
................................................................................
  return;
}


/*
 * C3d_Canvas_WorldChanged
 */
static void
C3d_Canvas_WorldChanged(ClientData clientData)
{
  C3dWidget *pCanvas = (C3dWidget *)clientData;

  Tk_GeometryRequest(pCanvas->tkwin, Tk_Width(pCanvas->tkwin),
          Tk_Height(pCanvas->tkwin));
  Tk_SetInternalBorder(pCanvas->tkwin, 0);

  if (Tk_IsMapped(pCanvas->tkwin)) {







<

<
<
<
<
<
<
<
<
<
<
<
<
>







 







<
<
<







 







<


<
<
<
<
<
<
<
<
<
<
<
<







 







<
|
<







46
47
48
49
50
51
52

53












54
55
56
57
58
59
60
61
...
226
227
228
229
230
231
232



233
234
235
236
237
238
239
...
277
278
279
280
281
282
283

284
285












286
287
288
289
290
291
292
...
555
556
557
558
559
560
561

562

563
564
565
566
567
568
569
static void C3d_Canvas_EventProc(ClientData clientData, XEvent *eventPtr);
static void C3d_Canvas_Delete(ClientData clientData);
#ifdef C3dFree
static void C3dFreeFunc(ClientData clientData);
#endif

static void C3d_Canvas_DrawWhenIdle(ClientData clientData);















/*
 *---------------------------------------------------------------------------
 *
 * vertexOptionSet --
 *
 *     The functions vertexOptionSet(), vertexOptionGet(),
 *     vertexOptionFree() and vertexOptionRestore() implement a Tk option
................................................................................
    vertexOptionFree,
    0
};

/*
 * Possible values for the C3dWidgetOptions.saveunder variable:
 */



static const char * SaveunderStrings[] = {"none", "3d", "all", 0};

/*
 * The option_spec array defines the widget options accepted by the
 * [$win configure], [$win cget] and [canvas3d] commands. To neaten things
 * up, Tk_OptionSpec instances are populated using the WIDGET_OPTION macro.
 */
................................................................................
** C3d_Native_ResizeContext -> Function to syncronize the size of the GL windows with the Tk Window
** C3d_Native_DeleteContext -> Function to delete a GL context after TK destroyed
** C3d_Native_CreateCanvas3d -> Function to produce an openGL context and canvas
** C3d_Native_Pixmap3dToPixmap -> Function to Copy from C3dPixmap.pixmap to C3dPixmap.pixmap3d
** C3d_Native_PixmapToPixmap3d -> Function to Copy from C3dPixmap.pixmap3d to C3dPixmap.pixmap
** C3d_Native_PixmapToWindow -> Copy pixmap to main window
** C3d_Native_EventProc -> Function to handle <Expose> events

*/













/*
 *---------------------------------------------------------------------------
 *
 * C3d_Canvas_DrawNow --
 *
 *     Redraw the entire widget. This function also resizes the X-window if
 *     the size of the Tk window has changed. This function is usually
................................................................................
  return;
}


/*
 * C3d_Canvas_WorldChanged
 */

void C3d_Canvas_WorldChanged(ClientData clientData) {

  C3dWidget *pCanvas = (C3dWidget *)clientData;

  Tk_GeometryRequest(pCanvas->tkwin, Tk_Width(pCanvas->tkwin),
          Tk_Height(pCanvas->tkwin));
  Tk_SetInternalBorder(pCanvas->tkwin, 0);

  if (Tk_IsMapped(pCanvas->tkwin)) {

Changes to macosx/c3dCarbonMain.c.















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
..
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
..
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
..
81
82
83
84
85
86
87
88
89
90
91
92
93

94
95
96
97
98
99
100
...
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
...
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
...
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
...
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
...
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
...
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
...
401
402
403
404
405
406
407
408
409
410
411














const Tk_ClassProcs C3dCanvasProcs = {
    sizeof(Tk_ClassProcs),	/* size */
    C3d_Canvas_WorldChanged,	/* worldChangedProc */
    C3d_Native_CreateCanvas3d,	/* createProc */
    NULL		        /* modalProc */
};

static void C3d_Native_ResizeContext(C3dWidget *pCanvas,int w,int h) {
  Window xwin = Tk_WindowId(pCanvas->tkwin);
  XResizeWindow(Tk_Display(pCanvas->tkwin), xwin, w, h);
  pCanvas->options.width = w;
  pCanvas->options.height = h;
}

/*
................................................................................
 *     This file contains the implementation of the Tcl interface of the
 *     canvas3d widget on Macos X running Carbon.
 *
 *     This file is called by an include directive in c3dmain.c
 *-------------------------------------------------------------------------
 */

static void C3d_Native_DeleteContext(C3dWidget *pCanvas) {
  aglDestroyContext(pCanvas->context);
}


/*
 *---------------------------------------------------------------------------
 *
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void 
C3d_Native_FreePixMaps(pCanvas)
    C3dWidget *pCanvas;
{
    pCanvas->pixmapheight = 0;
    pCanvas->pixmapwidth = 0;
    if (pCanvas->pixmap) {
        C3dFreePixmap(Tk_Display(pCanvas->tkwin), pCanvas->pixmap);
        pCanvas->pixmap = 0;
    }
    if (pCanvas->context) {
................................................................................
 *     X-window Window identifier to be wrapped into a Tk_Window by Tk.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static Window 
C3d_Native_CreateCanvas3d(tkwin, parent, clientData)
    Tk_Window tkwin; 
    Window parent;                /* X-windows wrapper around parent HWND */
    ClientData clientData;
{

    /*
    ** Here we initialize for Apple AGL
    */
    GLint   _attribs[32], attribs[] = {
	AGL_RGBA, AGL_DOUBLEBUFFER, AGL_DEPTH_SIZE, 24, AGL_NONE
    };
    GLint swapInterval = 1;
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void 
C3d_Native_Select3dContext(pCanvas)
    C3dWidget *pCanvas;
{
    Tk_Window win = pCanvas->tkwin;
    Display *dpy = Tk_Display(win);
    int saveunder = pCanvas->options.saveunder;
    int w = Tk_Width(win);
    int h = Tk_Height(win);

    /* If the -saveunder mode is not "none", then we need at least
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void 
C3d_Native_Release3dContext(pCanvas)
    C3dWidget *pCanvas;
{
}


/*
 *---------------------------------------------------------------------------
 *
 * C3d_Native_Pixmap3dToPixmap --
 *
 *     Copy from C3dPixmap.pixmap to C3dPixmap.pixmap3d.
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void C3d_Native_Pixmap3dToPixmap(pCanvas)
    C3dWidget *pCanvas;
{
    int w = pCanvas->pixmapwidth;
    int h = pCanvas->pixmapheight;

    w = h; /* lint */
    assert(!"cannot happen");
}

................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void C3d_Native_PixmapToPixmap3d(pCanvas)
    C3dWidget *pCanvas;
{
  assert(!"Cannot happen");
}

/* tell OpenGL which part of the Mac window to render to */
static void
SetMacBufRect(C3dWidget *pCanvas)
{
    Tk_Window tkwin = pCanvas->tkwin;
    Rect    r;
#if 0
    GLint   wrect[4];

    /* set wrect[0,1] to lower left corner of widget */
    wrect[2] = Tk_Width(tkwin);
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void C3d_Native_PixmapToWindow(pCanvas)
    C3dWidget *pCanvas;
{
    if (pCanvas->options.saveunder == SAVEUNDER_NONE) {
	SetMacBufRect(pCanvas);
        aglSwapBuffers(pCanvas->context);
    } else {
        int w = pCanvas->pixmapwidth;
        int h = pCanvas->pixmapheight;
        Tk_Window win = pCanvas->tkwin;
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void 
C3d_Native_EventProc(ClientData clientData, XEvent *eventPtr){
    C3dWidget *pCanvas = (C3dWidget *)clientData;
    switch (eventPtr->type) {
      case MapNotify: {
          AGLDrawable d = TkMacOSXGetDrawablePort(Tk_WindowId(pCanvas->tkwin));
          aglSetDrawable(pCanvas->context, d);
          break;
      }
................................................................................
           */
          aglSetDrawable(pCanvas->context, NULL);
          break;
      }
  }
}

static int C3d_Native_Init(Tcl_Interp *interp) {
  tkMacOSXGCEnabled = ([NSGarbageCollector defaultCollector] != nil);
  return TCL_OK;
}
>
>
>
>
>
>
>
>
>
>
>
>
>
>







|







 







|







 







<
|
<
<







 







<
|
|
|
|
<
>







 







<
|
<
<







 







<
|
<
<
<
<







 







|
<
<







 







|
<
<




<
|
<







 







|
<
<







 







<
|







 







|



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
..
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
..
60
61
62
63
64
65
66

67


68
69
70
71
72
73
74
..
92
93
94
95
96
97
98

99
100
101
102

103
104
105
106
107
108
109
110
...
204
205
206
207
208
209
210

211


212
213
214
215
216
217
218
...
255
256
257
258
259
260
261

262




263
264
265
266
267
268
269
...
272
273
274
275
276
277
278
279


280
281
282
283
284
285
286
...
296
297
298
299
300
301
302
303


304
305
306
307

308

309
310
311
312
313
314
315
...
339
340
341
342
343
344
345
346


347
348
349
350
351
352
353
...
372
373
374
375
376
377
378

379
380
381
382
383
384
385
386
...
394
395
396
397
398
399
400
401
402
403
404
/*
** Each platform defines:
** Tk_ClassProcs C3dCanvasProcs -> Array of functions exposed directly to TK
** C3d_Native_Select3dContext -> Function to select a 3d window for GL rendering
** C3d_Native_ResizeContext -> Function to syncronize the size of the GL windows with the Tk Window
** C3d_Native_DeleteContext -> Function to delete a GL context after TK destroyed
** C3d_Native_CreateCanvas3d -> Function to produce an openGL context and canvas
** C3d_Native_Pixmap3dToPixmap -> Function to Copy from C3dPixmap.pixmap to C3dPixmap.pixmap3d
** C3d_Native_PixmapToPixmap3d -> Function to Copy from C3dPixmap.pixmap3d to C3dPixmap.pixmap
** C3d_Native_PixmapToWindow -> Copy pixmap to main window
** C3d_Native_EventProc -> Function to handle <Expose> events
*/
#include "c3d.h"

const Tk_ClassProcs C3dCanvasProcs = {
    sizeof(Tk_ClassProcs),	/* size */
    C3d_Canvas_WorldChanged,	/* worldChangedProc */
    C3d_Native_CreateCanvas3d,	/* createProc */
    NULL		        /* modalProc */
};

void C3d_Native_ResizeContext(C3dWidget *pCanvas,int w,int h) {
  Window xwin = Tk_WindowId(pCanvas->tkwin);
  XResizeWindow(Tk_Display(pCanvas->tkwin), xwin, w, h);
  pCanvas->options.width = w;
  pCanvas->options.height = h;
}

/*
................................................................................
 *     This file contains the implementation of the Tcl interface of the
 *     canvas3d widget on Macos X running Carbon.
 *
 *     This file is called by an include directive in c3dmain.c
 *-------------------------------------------------------------------------
 */

void C3d_Native_DeleteContext(C3dWidget *pCanvas) {
  aglDestroyContext(pCanvas->context);
}


/*
 *---------------------------------------------------------------------------
 *
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_FreePixMaps(C3dWidget *pCanvas) {


    pCanvas->pixmapheight = 0;
    pCanvas->pixmapwidth = 0;
    if (pCanvas->pixmap) {
        C3dFreePixmap(Tk_Display(pCanvas->tkwin), pCanvas->pixmap);
        pCanvas->pixmap = 0;
    }
    if (pCanvas->context) {
................................................................................
 *     X-window Window identifier to be wrapped into a Tk_Window by Tk.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

Window C3d_Native_CreateCanvas3d(
    Tk_Window tkwin,
    Window parent,                /* X-windows wrapper around parent HWND */
    ClientData clientData

) {
    /*
    ** Here we initialize for Apple AGL
    */
    GLint   _attribs[32], attribs[] = {
	AGL_RGBA, AGL_DOUBLEBUFFER, AGL_DEPTH_SIZE, 24, AGL_NONE
    };
    GLint swapInterval = 1;
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_Select3dContext(C3dWidget *pCanvas) {


    Tk_Window win = pCanvas->tkwin;
    Display *dpy = Tk_Display(win);
    int saveunder = pCanvas->options.saveunder;
    int w = Tk_Width(win);
    int h = Tk_Height(win);

    /* If the -saveunder mode is not "none", then we need at least
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_Release3dContext(C3dWidget *pCanvas) {}





/*
 *---------------------------------------------------------------------------
 *
 * C3d_Native_Pixmap3dToPixmap --
 *
 *     Copy from C3dPixmap.pixmap to C3dPixmap.pixmap3d.
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
void C3d_Native_Pixmap3dToPixmap(C3dWidget *pCanvas) {


    int w = pCanvas->pixmapwidth;
    int h = pCanvas->pixmapheight;

    w = h; /* lint */
    assert(!"cannot happen");
}

................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
void C3d_Native_PixmapToPixmap3d(C3dWidget *pCanvas) {


  assert(!"Cannot happen");
}

/* tell OpenGL which part of the Mac window to render to */

static void SetMacBufRect(C3dWidget *pCanvas) {

    Tk_Window tkwin = pCanvas->tkwin;
    Rect    r;
#if 0
    GLint   wrect[4];

    /* set wrect[0,1] to lower left corner of widget */
    wrect[2] = Tk_Width(tkwin);
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
void C3d_Native_PixmapToWindow(C3dWidget *pCanvas) {


    if (pCanvas->options.saveunder == SAVEUNDER_NONE) {
	SetMacBufRect(pCanvas);
        aglSwapBuffers(pCanvas->context);
    } else {
        int w = pCanvas->pixmapwidth;
        int h = pCanvas->pixmapheight;
        Tk_Window win = pCanvas->tkwin;
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_EventProc(ClientData clientData, XEvent *eventPtr){
    C3dWidget *pCanvas = (C3dWidget *)clientData;
    switch (eventPtr->type) {
      case MapNotify: {
          AGLDrawable d = TkMacOSXGetDrawablePort(Tk_WindowId(pCanvas->tkwin));
          aglSetDrawable(pCanvas->context, d);
          break;
      }
................................................................................
           */
          aglSetDrawable(pCanvas->context, NULL);
          break;
      }
  }
}

int C3d_Native_Init(Tcl_Interp *interp) {
  tkMacOSXGCEnabled = ([NSGarbageCollector defaultCollector] != nil);
  return TCL_OK;
}

Changes to macosx/c3dCocoaMain.c.














1
2
3
4
5
6
7
.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
..
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
...
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
...
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
...
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
...
228
229
230
231
232
233
234
235
236
237
238
239
240

241
242
243
244
245
246
247
...
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
...
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
...
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
...
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368













#include <tkMacOSXPrivate.h>

#ifndef MACOSX_HITHEME
/* Private things from tk */
int tkMacOSXGCEnabled=0;
#endif

................................................................................
    sizeof(Tk_ClassProcs),	/* size */
    C3d_Canvas_WorldChanged,	/* worldChangedProc */
    C3d_Native_CreateCanvas3d,	/* createProc */
    NULL		        /* modalProc */
};

/* Copy of a non-exported function from Tk */
NSView*
canvas3dMacOSXDrawableView(
    MacDrawable *macWin)
{
    NSView *result = nil;

    if (!macWin) {
	result = nil;
    } else if (!macWin->toplevel) {
	result = macWin->view;
    } else if (!(macWin->toplevel->flags & TK_EMBEDDED)) {
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void 
C3d_Native_Select3dContext(pCanvas)
    C3dWidget *pCanvas;
{     
    Tk_Window tkwin = pCanvas->tkwin;
    TkWindow *winPtr = (TkWindow *) tkwin;  
    MacDrawable *macWin =  (MacDrawable *) winPtr->window;
    NSView *view = canvas3dMacOSXDrawableView(macWin);
    int saveunder = pCanvas->options.saveunder;
    int w = Tk_Width(tkwin);
    int h = Tk_Height(tkwin);
................................................................................
    assert(saveunder == SAVEUNDER_NONE || h == pCanvas->pixmapheight);

    /* If the -saveunder mode is "3d", then we also need C3dWidget.pixmap3d */
    if (saveunder == SAVEUNDER_3D && !pCanvas->pixmap3d) {
        /* Noop.  saveunder is not yet supported on AGL */
    }


    /* Finally, select the appropriate context. */
    [[pCanvas->context openGLContext] makeCurrentContext];
    pCanvas->options.width = w;
    pCanvas->options.height = h;
    glViewport(0, 0, w, h);
}

static void C3d_Native_Release3dContext(pCanvas)
    C3dWidget *pCanvas;
{
}

static void C3d_Native_ResizeContext(C3dWidget *pCanvas,int w,int h) {
  Window xwin = Tk_WindowId(pCanvas->tkwin);
  Rect r, rt;
  NSRect    rect;
  TkWindow *tkw = (TkWindow *) pCanvas->tkwin;
  TkWindow *tkt = tkw->privatePtr->toplevel->winPtr;

  XResizeWindow(Tk_Display(pCanvas->tkwin), xwin, w, h);
................................................................................
TODO: It appears that Tk only makes an NSView for toplevel windows.
Also it looks like NSOpenGL does not have the equivalent of AGL_BUFFER_RECT
that allows opengl drawing to just part of an NSView.  So we might need to
create our own NSView for controlling the opengl bounds.
Look at TkMacOSXMakeRealWindowExist() in tkMacOSXWm.c.
*/

static void C3d_Native_DeleteContext(C3dWidget *pCanvas) {
  if(pCanvas->context) {
#ifndef MACOSX_HITHEME
    TkMacOSXMakeCollectableAndRelease(pCanvas->context);
#endif
    pCanvas->context=nil;
  }
}
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void 
C3d_Native_FreePixMaps(pCanvas)
    C3dWidget *pCanvas;
{
    if (pCanvas->pixmap) {
        pCanvas->pixmapheight = 0;
        pCanvas->pixmapwidth = 0;
        C3dFreePixmap(Tk_Display(pCanvas->tkwin), pCanvas->pixmap);
        pCanvas->pixmap = 0;
    }
}
................................................................................
 *     X-window Window identifier to be wrapped into a Tk_Window by Tk.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static Window 
C3d_Native_CreateCanvas3d(tkwin, parent, clientData)
    Tk_Window tkwin; 
    Window parent;                /* X-windows wrapper around parent HWND */
    ClientData clientData;
{

    C3dWidget *pCanvas=(C3dWidget *)clientData;
    TkWindow *winPtr = (TkWindow *) tkwin;
    Display *pDisplay = Tk_Display(tkwin); /* Application display */

    Colormap cmap;
    Window window;
    pCanvas->tkwin=tkwin;
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void C3d_Native_Pixmap3dToPixmap(pCanvas)
    C3dWidget *pCanvas;
{
    int w = pCanvas->pixmapwidth;
    int h = pCanvas->pixmapheight;

    w = h; /* lint */
    assert(!"cannot happen");
}

................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void C3d_Native_PixmapToPixmap3d(pCanvas)
    C3dWidget *pCanvas;
{
  assert(!"Cannot happen");
}

/*
 *---------------------------------------------------------------------------
 *
 * C3d_Native_PixmapToWindow --
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void C3d_Native_PixmapToWindow(pCanvas)
    C3dWidget *pCanvas;
{
    [[pCanvas->context openGLContext] flushBuffer];
    if (pCanvas->options.saveunder != SAVEUNDER_NONE) {
        int w = pCanvas->pixmapwidth;
        int h = pCanvas->pixmapheight;
        Tk_Window win = pCanvas->tkwin;
        Window xwin = Tk_WindowId(win);
        GC gc = C3dGetGC(win, 0, 0);
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void 
C3d_Native_EventProc(ClientData clientData, XEvent *eventPtr){
}

static int C3d_Native_Init(Tcl_Interp *interp) {
#ifndef MACOSX_HITHEME
  tkMacOSXGCEnabled = ([NSGarbageCollector defaultCollector] != nil);
#endif
  return TCL_OK;
}
>
>
>
>
>
>
>
>
>
>
>
>
>







 







<
|
<
<







 







<
|
<
<







 







<







|
<
|
<
<
|







 







|







 







<
|
<
<







 







<
|
|
|
|
<
>







 







|
<
<







 







|
<
<







 







|
<
<







 







<
|
|
<
|





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
22
23
24
25
26
27
28

29


30
31
32
33
34
35
36
..
63
64
65
66
67
68
69

70


71
72
73
74
75
76
77
...
130
131
132
133
134
135
136

137
138
139
140
141
142
143
144

145


146
147
148
149
150
151
152
153
...
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
...
201
202
203
204
205
206
207

208


209
210
211
212
213
214
215
...
228
229
230
231
232
233
234

235
236
237
238

239
240
241
242
243
244
245
246
...
269
270
271
272
273
274
275
276


277
278
279
280
281
282
283
...
293
294
295
296
297
298
299
300


301
302
303
304
305
306
307
...
314
315
316
317
318
319
320
321


322
323
324
325
326
327
328
...
345
346
347
348
349
350
351

352
353

354
355
356
357
358
359
/*
** Each platform defines:
** Tk_ClassProcs C3dCanvasProcs -> Array of functions exposed directly to TK
** C3d_Native_Select3dContext -> Function to select a 3d window for GL rendering
** C3d_Native_ResizeContext -> Function to syncronize the size of the GL windows with the Tk Window
** C3d_Native_DeleteContext -> Function to delete a GL context after TK destroyed
** C3d_Native_CreateCanvas3d -> Function to produce an openGL context and canvas
** C3d_Native_Pixmap3dToPixmap -> Function to Copy from C3dPixmap.pixmap to C3dPixmap.pixmap3d
** C3d_Native_PixmapToPixmap3d -> Function to Copy from C3dPixmap.pixmap3d to C3dPixmap.pixmap
** C3d_Native_PixmapToWindow -> Copy pixmap to main window
** C3d_Native_EventProc -> Function to handle <Expose> events
*/
#include "c3d.h"
#include <tkMacOSXPrivate.h>

#ifndef MACOSX_HITHEME
/* Private things from tk */
int tkMacOSXGCEnabled=0;
#endif

................................................................................
    sizeof(Tk_ClassProcs),	/* size */
    C3d_Canvas_WorldChanged,	/* worldChangedProc */
    C3d_Native_CreateCanvas3d,	/* createProc */
    NULL		        /* modalProc */
};

/* Copy of a non-exported function from Tk */

static NSView* canvas3dMacOSXDrawableView(MacDrawable *macWin) {


    NSView *result = nil;

    if (!macWin) {
	result = nil;
    } else if (!macWin->toplevel) {
	result = macWin->view;
    } else if (!(macWin->toplevel->flags & TK_EMBEDDED)) {
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_Select3dContext( C3dWidget *pCanvas ) {


    Tk_Window tkwin = pCanvas->tkwin;
    TkWindow *winPtr = (TkWindow *) tkwin;  
    MacDrawable *macWin =  (MacDrawable *) winPtr->window;
    NSView *view = canvas3dMacOSXDrawableView(macWin);
    int saveunder = pCanvas->options.saveunder;
    int w = Tk_Width(tkwin);
    int h = Tk_Height(tkwin);
................................................................................
    assert(saveunder == SAVEUNDER_NONE || h == pCanvas->pixmapheight);

    /* If the -saveunder mode is "3d", then we also need C3dWidget.pixmap3d */
    if (saveunder == SAVEUNDER_3D && !pCanvas->pixmap3d) {
        /* Noop.  saveunder is not yet supported on AGL */
    }


    /* Finally, select the appropriate context. */
    [[pCanvas->context openGLContext] makeCurrentContext];
    pCanvas->options.width = w;
    pCanvas->options.height = h;
    glViewport(0, 0, w, h);
}

void C3d_Native_Release3dContext(C3dWidget *pCanvas) {}




void C3d_Native_ResizeContext(C3dWidget *pCanvas,int w,int h) {
  Window xwin = Tk_WindowId(pCanvas->tkwin);
  Rect r, rt;
  NSRect    rect;
  TkWindow *tkw = (TkWindow *) pCanvas->tkwin;
  TkWindow *tkt = tkw->privatePtr->toplevel->winPtr;

  XResizeWindow(Tk_Display(pCanvas->tkwin), xwin, w, h);
................................................................................
TODO: It appears that Tk only makes an NSView for toplevel windows.
Also it looks like NSOpenGL does not have the equivalent of AGL_BUFFER_RECT
that allows opengl drawing to just part of an NSView.  So we might need to
create our own NSView for controlling the opengl bounds.
Look at TkMacOSXMakeRealWindowExist() in tkMacOSXWm.c.
*/

void C3d_Native_DeleteContext(C3dWidget *pCanvas) {
  if(pCanvas->context) {
#ifndef MACOSX_HITHEME
    TkMacOSXMakeCollectableAndRelease(pCanvas->context);
#endif
    pCanvas->context=nil;
  }
}
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_FreePixMaps(C3dWidget *pCanvas) {


    if (pCanvas->pixmap) {
        pCanvas->pixmapheight = 0;
        pCanvas->pixmapwidth = 0;
        C3dFreePixmap(Tk_Display(pCanvas->tkwin), pCanvas->pixmap);
        pCanvas->pixmap = 0;
    }
}
................................................................................
 *     X-window Window identifier to be wrapped into a Tk_Window by Tk.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

Window C3d_Native_CreateCanvas3d(
    Tk_Window tkwin, 
    Window parent,               /* X-windows wrapper around parent HWND */
    ClientData clientData

) {
    C3dWidget *pCanvas=(C3dWidget *)clientData;
    TkWindow *winPtr = (TkWindow *) tkwin;
    Display *pDisplay = Tk_Display(tkwin); /* Application display */

    Colormap cmap;
    Window window;
    pCanvas->tkwin=tkwin;
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
void C3d_Native_Pixmap3dToPixmap(C3dWidget *pCanvas) {


    int w = pCanvas->pixmapwidth;
    int h = pCanvas->pixmapheight;

    w = h; /* lint */
    assert(!"cannot happen");
}

................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
void C3d_Native_PixmapToPixmap3d(C3dWidget *pCanvas) {


  assert(!"Cannot happen");
}

/*
 *---------------------------------------------------------------------------
 *
 * C3d_Native_PixmapToWindow --
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
void C3d_Native_PixmapToWindow(C3dWidget *pCanvas) {


    [[pCanvas->context openGLContext] flushBuffer];
    if (pCanvas->options.saveunder != SAVEUNDER_NONE) {
        int w = pCanvas->pixmapwidth;
        int h = pCanvas->pixmapheight;
        Tk_Window win = pCanvas->tkwin;
        Window xwin = Tk_WindowId(win);
        GC gc = C3dGetGC(win, 0, 0);
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_EventProc(ClientData clientData, XEvent *eventPtr){}


int C3d_Native_Init(Tcl_Interp *interp) {
#ifndef MACOSX_HITHEME
  tkMacOSXGCEnabled = ([NSGarbageCollector defaultCollector] != nil);
#endif
  return TCL_OK;
}

Changes to sdl/c3dSDLMain.c.















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
..
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
..
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
..
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
...
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
...
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
...
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
...
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
...
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308














const Tk_ClassProcs C3dCanvasProcs = {
    sizeof(Tk_ClassProcs),	/* size */
    C3d_Canvas_WorldChanged,	/* worldChangedProc */
    C3d_Native_CreateCanvas3d,  /* createProc */
    NULL		        /* modalProc */
};

static void
C3d_Native_ResizeContext(C3dWidget *pCanvas,int w,int h)
{
    Window xwin = Tk_WindowId(pCanvas->tkwin);
    XResizeWindow(Tk_Display(pCanvas->tkwin), xwin, w, h);
    pCanvas->options.width = w;
    pCanvas->options.height = h;
}

/*
................................................................................
 *
 *     This file contains the implementation of the Tcl interface of the
 *     canvas3d widget in SDL environments.
 *
 *     This file is called by an include directive in c3dmain.c
 *-------------------------------------------------------------------------
 */
static void
C3d_Native_DeleteContext(C3dWidget *pCanvas)
{
    if ((pCanvas->tkwin != NULL) && (pCanvas->context != NULL)) {
	SdlTkGLXDestroyContext(Tk_Display(pCanvas->tkwin),
			       Tk_WindowId(pCanvas->tkwin),
			       pCanvas->context);
	pCanvas->context = NULL;
    }
}
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void
C3d_Native_FreePixMaps(C3dWidget *pCanvas)
{
    pCanvas->pixmapheight = 0;
    pCanvas->pixmapwidth = 0;
    if (pCanvas->pixmap && pCanvas->tkwin) {
        C3dFreePixmap(Tk_Display(pCanvas->tkwin), pCanvas->pixmap);
        pCanvas->pixmap = 0;
    }
}
................................................................................
 *     X-window Window identifier to be wrapped into a Tk_Window by Tk.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static Window
C3d_Native_CreateCanvas3d(
    Tk_Window tkwin,
    Window parent,                /* X-windows wrapper around parent HWND */
    ClientData clientData
) {
    /* The rest of this function is the X11 version. */
    C3dWidget *pCanvas = (C3dWidget *)clientData;
    Display *pDisplay = Tk_Display(tkwin); /* Application display */
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void
C3d_Native_Select3dContext(C3dWidget *pCanvas)
{
    Tk_Window win = pCanvas->tkwin;
    int saveunder = pCanvas->options.saveunder;
    int w = Tk_Width(win);
    int h = Tk_Height(win);

    /* If the -saveunder mode is not "none", then we need at least
     * C3dWidget.pixmap.
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void
C3d_Native_Release3dContext(C3dWidget *pCanvas)
{
    Tk_Window win = pCanvas->tkwin;

    SdlTkGLXReleaseCurrent(Tk_Display(win), Tk_WindowId(win), pCanvas->context);
}

/*
 *---------------------------------------------------------------------------
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void
C3d_Native_Pixmap3dToPixmap(C3dWidget *pCanvas)
{
}

/*
 *---------------------------------------------------------------------------
 *
 * C3d_Native_PixmapToPixmap3d --
 *
 *     Copy from C3dPixmap.pixmap3d to C3dPixmap.pixmap.
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void
C3d_Native_PixmapToPixmap3d(C3dWidget *pCanvas)
{
}

/*
 *---------------------------------------------------------------------------
 *
 * C3d_Native_PixmapToWindow --
 *
 *     If the -saveunder mode is not "none", copy from the pixmap
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void
C3d_Native_PixmapToWindow(C3dWidget *pCanvas)
{
    glFlush();
    SdlTkGLXSwapBuffers(Tk_Display(pCanvas->tkwin),
			Tk_WindowId(pCanvas->tkwin));
}

/*
 *---------------------------------------------------------------------------
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void
C3d_Native_EventProc(ClientData clientData, XEvent *eventPtr)
{
    C3dWidget *pCanvas = (C3dWidget *)clientData;
    if (eventPtr->type == MapNotify) {
        C3dDrawWhenIdle(pCanvas, STATE_REDRAW_ALL);
    }
}

static int
C3d_Native_Init(Tcl_Interp *interp)
{
    if (0) {
	/* Squelch compiler warning */
	C3d_Native_ResizeContext(NULL, 0, 0);
    }
    if (0) {
	/* Squelch compiler warning */
	C3d_Native_Pixmap3dToPixmap(NULL);
    }
    return TCL_OK;
}
>
>
>
>
>
>
>
>
>
>
>
>
>
>







<
|
<







 







<
|
<







 







<
|
<







 







<
|







 







<
|
<







 







<
|
<







 







<
|
<
<







 







<
|
<
<







 







<
|
<







 







<
|
<






<
|
<










1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

22

23
24
25
26
27
28
29
..
31
32
33
34
35
36
37

38

39
40
41
42
43
44
45
..
63
64
65
66
67
68
69

70

71
72
73
74
75
76
77
..
90
91
92
93
94
95
96

97
98
99
100
101
102
103
104
...
153
154
155
156
157
158
159

160

161
162
163
164
165
166
167
...
195
196
197
198
199
200
201

202

203
204
205
206
207
208
209
...
216
217
218
219
220
221
222

223


224
225
226
227
228
229
230
...
233
234
235
236
237
238
239

240


241
242
243
244
245
246
247
...
252
253
254
255
256
257
258

259

260
261
262
263
264
265
266
...
275
276
277
278
279
280
281

282

283
284
285
286
287
288

289

290
291
292
293
294
295
296
297
298
299
/*
** Each platform defines:
** Tk_ClassProcs C3dCanvasProcs -> Array of functions exposed directly to TK
** C3d_Native_Select3dContext -> Function to select a 3d window for GL rendering
** C3d_Native_ResizeContext -> Function to syncronize the size of the GL windows with the Tk Window
** C3d_Native_DeleteContext -> Function to delete a GL context after TK destroyed
** C3d_Native_CreateCanvas3d -> Function to produce an openGL context and canvas
** C3d_Native_Pixmap3dToPixmap -> Function to Copy from C3dPixmap.pixmap to C3dPixmap.pixmap3d
** C3d_Native_PixmapToPixmap3d -> Function to Copy from C3dPixmap.pixmap3d to C3dPixmap.pixmap
** C3d_Native_PixmapToWindow -> Copy pixmap to main window
** C3d_Native_EventProc -> Function to handle <Expose> events
*/
#include "c3d.h"

const Tk_ClassProcs C3dCanvasProcs = {
    sizeof(Tk_ClassProcs),	/* size */
    C3d_Canvas_WorldChanged,	/* worldChangedProc */
    C3d_Native_CreateCanvas3d,  /* createProc */
    NULL		        /* modalProc */
};


void C3d_Native_ResizeContext(C3dWidget *pCanvas,int w,int h) {

    Window xwin = Tk_WindowId(pCanvas->tkwin);
    XResizeWindow(Tk_Display(pCanvas->tkwin), xwin, w, h);
    pCanvas->options.width = w;
    pCanvas->options.height = h;
}

/*
................................................................................
 *
 *     This file contains the implementation of the Tcl interface of the
 *     canvas3d widget in SDL environments.
 *
 *     This file is called by an include directive in c3dmain.c
 *-------------------------------------------------------------------------
 */

void C3d_Native_DeleteContext(C3dWidget *pCanvas) {

    if ((pCanvas->tkwin != NULL) && (pCanvas->context != NULL)) {
	SdlTkGLXDestroyContext(Tk_Display(pCanvas->tkwin),
			       Tk_WindowId(pCanvas->tkwin),
			       pCanvas->context);
	pCanvas->context = NULL;
    }
}
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_FreePixMaps(C3dWidget *pCanvas) {

    pCanvas->pixmapheight = 0;
    pCanvas->pixmapwidth = 0;
    if (pCanvas->pixmap && pCanvas->tkwin) {
        C3dFreePixmap(Tk_Display(pCanvas->tkwin), pCanvas->pixmap);
        pCanvas->pixmap = 0;
    }
}
................................................................................
 *     X-window Window identifier to be wrapped into a Tk_Window by Tk.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

Window C3d_Native_CreateCanvas3d(
    Tk_Window tkwin,
    Window parent,                /* X-windows wrapper around parent HWND */
    ClientData clientData
) {
    /* The rest of this function is the X11 version. */
    C3dWidget *pCanvas = (C3dWidget *)clientData;
    Display *pDisplay = Tk_Display(tkwin); /* Application display */
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_Select3dContext(C3dWidget *pCanvas) {

    Tk_Window win = pCanvas->tkwin;
    int saveunder = pCanvas->options.saveunder;
    int w = Tk_Width(win);
    int h = Tk_Height(win);

    /* If the -saveunder mode is not "none", then we need at least
     * C3dWidget.pixmap.
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_Release3dContext(C3dWidget *pCanvas) {

    Tk_Window win = pCanvas->tkwin;

    SdlTkGLXReleaseCurrent(Tk_Display(win), Tk_WindowId(win), pCanvas->context);
}

/*
 *---------------------------------------------------------------------------
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_Pixmap3dToPixmap(C3dWidget *pCanvas) {}



/*
 *---------------------------------------------------------------------------
 *
 * C3d_Native_PixmapToPixmap3d --
 *
 *     Copy from C3dPixmap.pixmap3d to C3dPixmap.pixmap.
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_PixmapToPixmap3d(C3dWidget *pCanvas) {}



/*
 *---------------------------------------------------------------------------
 *
 * C3d_Native_PixmapToWindow --
 *
 *     If the -saveunder mode is not "none", copy from the pixmap
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_PixmapToWindow(C3dWidget *pCanvas) {

    glFlush();
    SdlTkGLXSwapBuffers(Tk_Display(pCanvas->tkwin),
			Tk_WindowId(pCanvas->tkwin));
}

/*
 *---------------------------------------------------------------------------
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_EventProc(ClientData clientData, XEvent *eventPtr) {

    C3dWidget *pCanvas = (C3dWidget *)clientData;
    if (eventPtr->type == MapNotify) {
        C3dDrawWhenIdle(pCanvas, STATE_REDRAW_ALL);
    }
}


int C3d_Native_Init(Tcl_Interp *interp) {

    if (0) {
	/* Squelch compiler warning */
	C3d_Native_ResizeContext(NULL, 0, 0);
    }
    if (0) {
	/* Squelch compiler warning */
	C3d_Native_Pixmap3dToPixmap(NULL);
    }
    return TCL_OK;
}

Changes to unix/c3dX11Main.c.















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
..
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
..
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
..
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
...
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
...
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
...
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
...
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
...
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
...
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390














const Tk_ClassProcs C3dCanvasProcs = {
    sizeof(Tk_ClassProcs),	/* size */
    C3d_Canvas_WorldChanged,	/* worldChangedProc */
    C3d_Native_CreateCanvas3d,  /* createProc */
    NULL		        /* modalProc */
};

static void
C3d_Native_ResizeContext(C3dWidget *pCanvas,int w,int h)
{
    XResizeWindow(pCanvas->display, Tk_WindowId(pCanvas->tkwin), w, h);
    pCanvas->options.width = w;
    pCanvas->options.height = h;
}

/*
 * cd3X11Main.c --
................................................................................
 *
 *     This file contains the implementation of the Tcl interface of the
 *     canvas3d widget in X11 windowing environments.
 *
 *     This file is called by an include directive in c3dmain.c
 *-------------------------------------------------------------------------
 */
static void
C3d_Native_DeleteContext(C3dWidget *pCanvas) {
    glXDestroyContext(pCanvas->display, pCanvas->context);
}

/*
 *---------------------------------------------------------------------------
 *
 * C3d_Native_FreePixMaps --
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void
C3d_Native_FreePixMaps(C3dWidget *pCanvas)
{
    pCanvas->pixmapheight = 0;
    pCanvas->pixmapwidth = 0;
    if (pCanvas->pixmap) {
        C3dFreePixmap(pCanvas->display, pCanvas->pixmap);
        pCanvas->pixmap = 0;
    }
    if (pCanvas->glxpixmap) {
................................................................................
 *     X-window Window identifier to be wrapped into a Tk_Window by Tk.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static Window
C3d_Native_CreateCanvas3d(
    Tk_Window tkwin,
    Window parent,                /* X-windows wrapper around parent HWND */
    ClientData clientData
) {
    /* The rest of this function is the X11 version. */
    C3dWidget *pCanvas = (C3dWidget *)clientData;
    Tcl_Interp *interp = pCanvas->interp;
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void
C3d_Native_Select3dContext(C3dWidget *pCanvas)
{
    Tk_Window win = pCanvas->tkwin;
    Display *dpy = pCanvas->display;
    int saveunder = pCanvas->options.saveunder;
    int w = Tk_Width(win);
    int h = Tk_Height(win);

    /* If the -saveunder mode is not "none", then we need at least
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void
C3d_Native_Release3dContext(C3dWidget *pCanvas)
{
}

/*
 *---------------------------------------------------------------------------
 *
 * C3d_Native_Pixmap3dToPixmap --
 *
 *     Copy from C3dPixmap.pixmap to C3dPixmap.pixmap3d.
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void
C3d_Native_Pixmap3dToPixmap(C3dWidget *pCanvas)
{
    int w = pCanvas->pixmapwidth;
    int h = pCanvas->pixmapheight;

    Pixmap dest = pCanvas->pixmap;
    Pixmap src = pCanvas->pixmap3d;
    GC gc = C3dGetGC(pCanvas->tkwin, 0, 0);
    assert(src && dest);
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void
C3d_Native_PixmapToPixmap3d(C3dWidget *pCanvas)
{
    int w = pCanvas->pixmapwidth;
    int h = pCanvas->pixmapheight;

    Pixmap dest = pCanvas->pixmap3d;
    Pixmap src = pCanvas->pixmap;
    GC gc = C3dGetGC(pCanvas->tkwin, 0, 0);
    assert(src && dest);
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void
C3d_Native_PixmapToWindow(C3dWidget *pCanvas)
{
    if (pCanvas->options.saveunder == SAVEUNDER_NONE) {
        glXSwapBuffers(pCanvas->display, Tk_WindowId(pCanvas->tkwin));
    } else {
        int w = pCanvas->pixmapwidth;
        int h = pCanvas->pixmapheight;
        GC gc = C3dGetGC(pCanvas->tkwin, 0, 0);
	assert(pCanvas->pixmap);
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void
C3d_Native_EventProc(ClientData clientData, XEvent *eventPtr)
{
}

static int
C3d_Native_Init(Tcl_Interp *interp)
{
    if (0) {
	/* Squelch compiler warning */
	C3d_Native_ResizeContext(NULL, 0, 0);
    }
    if (0) {
	/* Squelch compiler warning */
	C3d_Native_Pixmap3dToPixmap(NULL);
    }
    return TCL_OK;
}
>
>
>
>
>
>
>
>
>
>
>
>
>
>







<
|
<







 







<
|







 







<
|
<







 







<
|







 







<
|
<







 







<
|
<
<







 







<
|
<







 







<
|
<







 







<
|
<







 







<
|
|
<
<
<
|
<










1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

22

23
24
25
26
27
28
29
..
30
31
32
33
34
35
36

37
38
39
40
41
42
43
44
..
57
58
59
60
61
62
63

64

65
66
67
68
69
70
71
..
96
97
98
99
100
101
102

103
104
105
106
107
108
109
110
...
186
187
188
189
190
191
192

193

194
195
196
197
198
199
200
...
259
260
261
262
263
264
265

266


267
268
269
270
271
272
273
...
276
277
278
279
280
281
282

283

284
285
286
287
288
289
290
...
303
304
305
306
307
308
309

310

311
312
313
314
315
316
317
...
332
333
334
335
336
337
338

339

340
341
342
343
344
345
346
...
363
364
365
366
367
368
369

370
371



372

373
374
375
376
377
378
379
380
381
382
/*
** Each platform defines:
** Tk_ClassProcs C3dCanvasProcs -> Array of functions exposed directly to TK
** C3d_Native_Select3dContext -> Function to select a 3d window for GL rendering
** C3d_Native_ResizeContext -> Function to syncronize the size of the GL windows with the Tk Window
** C3d_Native_DeleteContext -> Function to delete a GL context after TK destroyed
** C3d_Native_CreateCanvas3d -> Function to produce an openGL context and canvas
** C3d_Native_Pixmap3dToPixmap -> Function to Copy from C3dPixmap.pixmap to C3dPixmap.pixmap3d
** C3d_Native_PixmapToPixmap3d -> Function to Copy from C3dPixmap.pixmap3d to C3dPixmap.pixmap
** C3d_Native_PixmapToWindow -> Copy pixmap to main window
** C3d_Native_EventProc -> Function to handle <Expose> events
*/
#include "c3d.h"

const Tk_ClassProcs C3dCanvasProcs = {
    sizeof(Tk_ClassProcs),	/* size */
    C3d_Canvas_WorldChanged,	/* worldChangedProc */
    C3d_Native_CreateCanvas3d,  /* createProc */
    NULL		        /* modalProc */
};


void C3d_Native_ResizeContext(C3dWidget *pCanvas,int w,int h) {

    XResizeWindow(pCanvas->display, Tk_WindowId(pCanvas->tkwin), w, h);
    pCanvas->options.width = w;
    pCanvas->options.height = h;
}

/*
 * cd3X11Main.c --
................................................................................
 *
 *     This file contains the implementation of the Tcl interface of the
 *     canvas3d widget in X11 windowing environments.
 *
 *     This file is called by an include directive in c3dmain.c
 *-------------------------------------------------------------------------
 */

void C3d_Native_DeleteContext(C3dWidget *pCanvas) {
    glXDestroyContext(pCanvas->display, pCanvas->context);
}

/*
 *---------------------------------------------------------------------------
 *
 * C3d_Native_FreePixMaps --
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_FreePixMaps(C3dWidget *pCanvas) {

    pCanvas->pixmapheight = 0;
    pCanvas->pixmapwidth = 0;
    if (pCanvas->pixmap) {
        C3dFreePixmap(pCanvas->display, pCanvas->pixmap);
        pCanvas->pixmap = 0;
    }
    if (pCanvas->glxpixmap) {
................................................................................
 *     X-window Window identifier to be wrapped into a Tk_Window by Tk.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

Window C3d_Native_CreateCanvas3d(
    Tk_Window tkwin,
    Window parent,                /* X-windows wrapper around parent HWND */
    ClientData clientData
) {
    /* The rest of this function is the X11 version. */
    C3dWidget *pCanvas = (C3dWidget *)clientData;
    Tcl_Interp *interp = pCanvas->interp;
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_Select3dContext(C3dWidget *pCanvas) {

    Tk_Window win = pCanvas->tkwin;
    Display *dpy = pCanvas->display;
    int saveunder = pCanvas->options.saveunder;
    int w = Tk_Width(win);
    int h = Tk_Height(win);

    /* If the -saveunder mode is not "none", then we need at least
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_Release3dContext(C3dWidget *pCanvas) {}



/*
 *---------------------------------------------------------------------------
 *
 * C3d_Native_Pixmap3dToPixmap --
 *
 *     Copy from C3dPixmap.pixmap to C3dPixmap.pixmap3d.
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_Pixmap3dToPixmap(C3dWidget *pCanvas) {

    int w = pCanvas->pixmapwidth;
    int h = pCanvas->pixmapheight;

    Pixmap dest = pCanvas->pixmap;
    Pixmap src = pCanvas->pixmap3d;
    GC gc = C3dGetGC(pCanvas->tkwin, 0, 0);
    assert(src && dest);
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_PixmapToPixmap3d(C3dWidget *pCanvas) {

    int w = pCanvas->pixmapwidth;
    int h = pCanvas->pixmapheight;

    Pixmap dest = pCanvas->pixmap3d;
    Pixmap src = pCanvas->pixmap;
    GC gc = C3dGetGC(pCanvas->tkwin, 0, 0);
    assert(src && dest);
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_PixmapToWindow(C3dWidget *pCanvas) {

    if (pCanvas->options.saveunder == SAVEUNDER_NONE) {
        glXSwapBuffers(pCanvas->display, Tk_WindowId(pCanvas->tkwin));
    } else {
        int w = pCanvas->pixmapwidth;
        int h = pCanvas->pixmapheight;
        GC gc = C3dGetGC(pCanvas->tkwin, 0, 0);
	assert(pCanvas->pixmap);
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_EventProc(ClientData clientData, XEvent *eventPtr) {}




int C3d_Native_Init(Tcl_Interp *interp) {

    if (0) {
	/* Squelch compiler warning */
	C3d_Native_ResizeContext(NULL, 0, 0);
    }
    if (0) {
	/* Squelch compiler warning */
	C3d_Native_Pixmap3dToPixmap(NULL);
    }
    return TCL_OK;
}

Changes to win/c3dWinMain.c.















1


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
...
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
...
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
...
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
...
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
...
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
...
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
...
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
...
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543














#include "tkInt.h"



const Tk_ClassProcs C3dCanvasProcs = {
    sizeof(Tk_ClassProcs),	/* size */
    C3d_Canvas_WorldChanged,	/* worldChangedProc */
    C3d_Native_CreateCanvas3d,	                /* createProc */
    NULL		        /* modalProc */
};

static void
C3d_Native_ResizeContext(C3dWidget *pCanvas,int w,int h)
{
    Window xwin = Tk_WindowId(pCanvas->tkwin);
    XResizeWindow(Tk_Display(pCanvas->tkwin), xwin, w, h);
    pCanvas->options.width = w;
    pCanvas->options.height = h;
}

/*
................................................................................
 *
 *     This file contains the implementation of the Tcl interface of the
 *     canvas3d widget on windows.
 *
 *     This file is called by an include directive in c3dmain.c
 *-------------------------------------------------------------------------
 */
static void
C3d_Native_DeleteContext(C3dWidget *pCanvas)
{
    wglDeleteContext(pCanvas->context);
}

/*
 *---------------------------------------------------------------------------
 *
 * windowsError --
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void
C3d_Native_FreePixMaps(C3dWidget *pCanvas)
{
    pCanvas->pixmapheight = 0;
    pCanvas->pixmapwidth = 0;
    if (pCanvas->pixmap) {
        C3dFreePixmap(Tk_Display(pCanvas->tkwin), pCanvas->pixmap);
        pCanvas->pixmap = 0;
    }

................................................................................
 *     X-window Window identifier to be wrapped into a Tk_Window by Tk.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static Window
C3d_Native_CreateCanvas3d(
    Tk_Window tkwin,
    Window parent,                /* X-windows wrapper around parent HWND */
    ClientData clientData
) {
    C3dWidget *pCanvas = (C3dWidget *)clientData;
    Tcl_Interp *interp = pCanvas->interp;

................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void
C3d_Native_Select3dContext(C3dWidget *pCanvas)
{
    Tk_Window win = pCanvas->tkwin;
    Display *dpy = Tk_Display(win);
    int saveunder = pCanvas->options.saveunder;
    int w = Tk_Width(win);
    int h = Tk_Height(win);

    /* On win32, "-saveunder all" behaves in the same way as "-saveunder 3d" */
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void
C3d_Native_Release3dContext(C3dWidget *pCanvas)
{
}

/*
 *---------------------------------------------------------------------------
 *
 * C3d_Native_Pixmap3dToPixmap --
 *
 *     Copy from C3dPixmap.pixmap to C3dPixmap.pixmap3d.
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void
C3d_Native_Pixmap3dToPixmap(C3dWidget *pCanvas)
{
    int w = pCanvas->pixmapwidth;
    int h = pCanvas->pixmapheight;

    HDC hDC = CreateCompatibleDC(NULL);
    HBITMAP hBitmap = getHBITMAP(pCanvas->pixmap);
    assert(pCanvas->pixmap && pCanvas->pixmap3d);
    SelectObject(hDC, hBitmap);
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void
C3d_Native_PixmapToPixmap3d(C3dWidget *pCanvas)
{
    assert(!"Cannot happen");
}

/*
 *---------------------------------------------------------------------------
 *
 * C3d_Native_PixmapToWindow --
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void
C3d_Native_PixmapToWindow(C3dWidget *pCanvas)
{
    if (pCanvas->options.saveunder == SAVEUNDER_NONE) {
        SwapBuffers(pCanvas->hDC);
    } else {
        int w = pCanvas->pixmapwidth;
        int h = pCanvas->pixmapheight;
        Tk_Window win = pCanvas->tkwin;
        Window xwin = Tk_WindowId(win);
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */
static void
C3d_Native_EventProc(ClientData clientData, XEvent *eventPtr)
{
}

static int
C3d_Native_Init(Tcl_Interp *interp)
{
    if (0) {
	/* Squelch compiler warning */
	C3d_Native_ResizeContext(NULL, 0, 0);
    }
    if (0) {
	/* Squelch compiler warning */
	C3d_Native_Pixmap3dToPixmap(NULL);
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
>








<
|
<







 







<
|
<







 







<
|
<







 







<
|







 







<
|
<







 







<
|
<
<







 







<
|
<







 







<
|
<







 







<
|
<







 







<
|
|
<
<
<
|
<







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

26

27
28
29
30
31
32
33
..
35
36
37
38
39
40
41

42

43
44
45
46
47
48
49
...
154
155
156
157
158
159
160

161

162
163
164
165
166
167
168
...
194
195
196
197
198
199
200

201
202
203
204
205
206
207
208
...
324
325
326
327
328
329
330

331

332
333
334
335
336
337
338
...
423
424
425
426
427
428
429

430


431
432
433
434
435
436
437
...
440
441
442
443
444
445
446

447

448
449
450
451
452
453
454
...
467
468
469
470
471
472
473

474

475
476
477
478
479
480
481
...
488
489
490
491
492
493
494

495

496
497
498
499
500
501
502
...
520
521
522
523
524
525
526

527
528



529

530
531
532
533
534
535
536
/*
** Each platform defines:
** Tk_ClassProcs C3dCanvasProcs -> Array of functions exposed directly to TK
** C3d_Native_Select3dContext -> Function to select a 3d window for GL rendering
** C3d_Native_ResizeContext -> Function to syncronize the size of the GL windows with the Tk Window
** C3d_Native_DeleteContext -> Function to delete a GL context after TK destroyed
** C3d_Native_CreateCanvas3d -> Function to produce an openGL context and canvas
** C3d_Native_Pixmap3dToPixmap -> Function to Copy from C3dPixmap.pixmap to C3dPixmap.pixmap3d
** C3d_Native_PixmapToPixmap3d -> Function to Copy from C3dPixmap.pixmap3d to C3dPixmap.pixmap
** C3d_Native_PixmapToWindow -> Copy pixmap to main window
** C3d_Native_EventProc -> Function to handle <Expose> events
*/

#include "c3d.h"
#include "tkInt.h"



const Tk_ClassProcs C3dCanvasProcs = {
    sizeof(Tk_ClassProcs),	/* size */
    C3d_Canvas_WorldChanged,	/* worldChangedProc */
    C3d_Native_CreateCanvas3d,	                /* createProc */
    NULL		        /* modalProc */
};


void C3d_Native_ResizeContext(C3dWidget *pCanvas,int w,int h) {

    Window xwin = Tk_WindowId(pCanvas->tkwin);
    XResizeWindow(Tk_Display(pCanvas->tkwin), xwin, w, h);
    pCanvas->options.width = w;
    pCanvas->options.height = h;
}

/*
................................................................................
 *
 *     This file contains the implementation of the Tcl interface of the
 *     canvas3d widget on windows.
 *
 *     This file is called by an include directive in c3dmain.c
 *-------------------------------------------------------------------------
 */

void C3d_Native_DeleteContext(C3dWidget *pCanvas) {

    wglDeleteContext(pCanvas->context);
}

/*
 *---------------------------------------------------------------------------
 *
 * windowsError --
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_FreePixMaps(C3dWidget *pCanvas) {

    pCanvas->pixmapheight = 0;
    pCanvas->pixmapwidth = 0;
    if (pCanvas->pixmap) {
        C3dFreePixmap(Tk_Display(pCanvas->tkwin), pCanvas->pixmap);
        pCanvas->pixmap = 0;
    }

................................................................................
 *     X-window Window identifier to be wrapped into a Tk_Window by Tk.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

Window C3d_Native_CreateCanvas3d(
    Tk_Window tkwin,
    Window parent,                /* X-windows wrapper around parent HWND */
    ClientData clientData
) {
    C3dWidget *pCanvas = (C3dWidget *)clientData;
    Tcl_Interp *interp = pCanvas->interp;

................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_Select3dContext(C3dWidget *pCanvas) {

    Tk_Window win = pCanvas->tkwin;
    Display *dpy = Tk_Display(win);
    int saveunder = pCanvas->options.saveunder;
    int w = Tk_Width(win);
    int h = Tk_Height(win);

    /* On win32, "-saveunder all" behaves in the same way as "-saveunder 3d" */
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_Release3dContext(C3dWidget *pCanvas) {}



/*
 *---------------------------------------------------------------------------
 *
 * C3d_Native_Pixmap3dToPixmap --
 *
 *     Copy from C3dPixmap.pixmap to C3dPixmap.pixmap3d.
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_Pixmap3dToPixmap(C3dWidget *pCanvas) {

    int w = pCanvas->pixmapwidth;
    int h = pCanvas->pixmapheight;

    HDC hDC = CreateCompatibleDC(NULL);
    HBITMAP hBitmap = getHBITMAP(pCanvas->pixmap);
    assert(pCanvas->pixmap && pCanvas->pixmap3d);
    SelectObject(hDC, hBitmap);
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_PixmapToPixmap3d(C3dWidget *pCanvas) {

    assert(!"Cannot happen");
}

/*
 *---------------------------------------------------------------------------
 *
 * C3d_Native_PixmapToWindow --
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_PixmapToWindow(C3dWidget *pCanvas) {

    if (pCanvas->options.saveunder == SAVEUNDER_NONE) {
        SwapBuffers(pCanvas->hDC);
    } else {
        int w = pCanvas->pixmapwidth;
        int h = pCanvas->pixmapheight;
        Tk_Window win = pCanvas->tkwin;
        Window xwin = Tk_WindowId(win);
................................................................................
 *     None.
 *
 * Side effects:
 *     None.
 *
 *---------------------------------------------------------------------------
 */

void C3d_Native_EventProc(ClientData clientData, XEvent *eventPtr) {}




int C3d_Native_Init(Tcl_Interp *interp) {

    if (0) {
	/* Squelch compiler warning */
	C3d_Native_ResizeContext(NULL, 0, 0);
    }
    if (0) {
	/* Squelch compiler warning */
	C3d_Native_Pixmap3dToPixmap(NULL);