2 /* Copyright (c) Nate Robins, 1997. */
4 /* portions Copyright (c) Mark Kilgard, 1997, 1998. */
6 /* This program is freely distributable without licensing fees
7 and is provided without guarantee or warrantee expressed or
8 implied. This program is -not- in the public domain. */
12 #include "glutstroke.h"
13 #include "glutbitmap.h"
14 #include <sys/timeb.h>
16 /* The following added by Paul Garceau <pgarceau@teleport.com> */
17 #if defined(__MINGW32__)
24 extern StrokeFontRec glutStrokeRoman
, glutStrokeMonoRoman
;
25 extern BitmapFontRec glutBitmap8By13
, glutBitmap9By15
, glutBitmapTimesRoman10
, glutBitmapTimesRoman24
, glutBitmapHelvetica10
, glutBitmapHelvetica12
, glutBitmapHelvetica18
;
29 gettimeofday(struct timeval
* tp
, void* tzp
)
35 tp
->tv_usec
= tb
.millitm
* 1000;
37 /* 0 indicates that the call succeeded. */
42 /* To get around the fact that Microsoft DLLs only allow functions
43 to be exported and now data addresses (as Unix DSOs support), the
44 GLUT API constants such as GLUT_STROKE_ROMAN have to get passed
45 through a case statement to get mapped to the actual data structure
48 __glutFont(void *font
)
51 case (int)GLUT_STROKE_ROMAN
:
52 return &glutStrokeRoman
;
53 case (int)GLUT_STROKE_MONO_ROMAN
:
54 return &glutStrokeMonoRoman
;
55 case (int)GLUT_BITMAP_9_BY_15
:
56 return &glutBitmap9By15
;
57 case (int)GLUT_BITMAP_8_BY_13
:
58 return &glutBitmap8By13
;
59 case (int)GLUT_BITMAP_TIMES_ROMAN_10
:
60 return &glutBitmapTimesRoman10
;
61 case (int)GLUT_BITMAP_TIMES_ROMAN_24
:
62 return &glutBitmapTimesRoman24
;
63 case (int)GLUT_BITMAP_HELVETICA_10
:
64 return &glutBitmapHelvetica10
;
65 case (int)GLUT_BITMAP_HELVETICA_12
:
66 return &glutBitmapHelvetica12
;
67 case (int)GLUT_BITMAP_HELVETICA_18
:
68 return &glutBitmapHelvetica18
;
70 __glutFatalError("font not found.");
72 return NULL
; /* MSVC compiler complains if there is no return at all */
76 __glutGetTransparentPixel(Display
* dpy
, XVisualInfo
* vinfo
)
78 /* the transparent pixel on Win32 is always index number 0. So if
79 we put this routine in this file, we can avoid compiling the
80 whole of layerutil.c which is where this routine normally comes
86 __glutAdjustCoords(Window parent
, int* x
, int* y
, int* width
, int* height
)
90 /* adjust the window rectangle because Win32 thinks that the x, y,
91 width & height are the WHOLE window (including decorations),
92 whereas GLUT treats the x, y, width & height as only the CLIENT
93 area of the window. */
94 rect
.left
= *x
; rect
.top
= *y
;
95 rect
.right
= *x
+ *width
; rect
.bottom
= *y
+ *height
;
97 /* must adjust the coordinates according to the correct style
98 because depending on the style, there may or may not be
100 AdjustWindowRect(&rect
, WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
|
101 (parent
? WS_CHILD
: WS_OVERLAPPEDWINDOW
),
103 /* FALSE in the third parameter = window has no menu bar */
105 /* readjust if the x and y are offscreen */
118 *width
= rect
.right
- rect
.left
; /* adjusted width */
119 *height
= rect
.bottom
- rect
.top
; /* adjusted height */