#include "glutint.h"
#include "glutstroke.h"
#include "glutbitmap.h"
#include <sys/timeb.h>
#if defined(__MINGW32__)
#include <GL/gl.h>
#include <time.h>
#include <windows.h>
struct timeval;
#endif
extern StrokeFontRec glutStrokeRoman, glutStrokeMonoRoman;
extern BitmapFontRec glutBitmap8By13, glutBitmap9By15, glutBitmapTimesRoman10, glutBitmapTimesRoman24, glutBitmapHelvetica10, glutBitmapHelvetica12, glutBitmapHelvetica18;
#ifndef __CYGWIN32__
int
gettimeofday(struct timeval* tp, void* tzp)
{
struct timeb tb;
ftime(&tb);
tp->tv_sec = tb.time;
tp->tv_usec = tb.millitm * 1000;
return 0;
}
#endif
void*
__glutFont(void *font)
{
switch((int)font) {
case (int)GLUT_STROKE_ROMAN:
return &glutStrokeRoman;
case (int)GLUT_STROKE_MONO_ROMAN:
return &glutStrokeMonoRoman;
case (int)GLUT_BITMAP_9_BY_15:
return &glutBitmap9By15;
case (int)GLUT_BITMAP_8_BY_13:
return &glutBitmap8By13;
case (int)GLUT_BITMAP_TIMES_ROMAN_10:
return &glutBitmapTimesRoman10;
case (int)GLUT_BITMAP_TIMES_ROMAN_24:
return &glutBitmapTimesRoman24;
case (int)GLUT_BITMAP_HELVETICA_10:
return &glutBitmapHelvetica10;
case (int)GLUT_BITMAP_HELVETICA_12:
return &glutBitmapHelvetica12;
case (int)GLUT_BITMAP_HELVETICA_18:
return &glutBitmapHelvetica18;
}
__glutFatalError("font not found.");
return NULL;
}
int
__glutGetTransparentPixel(Display * dpy, XVisualInfo * vinfo)
{
return 0;
}
void
__glutAdjustCoords(Window parent, int* x, int* y, int* width, int* height)
{
RECT rect;
rect.left = *x; rect.top = *y;
rect.right = *x + *width; rect.bottom = *y + *height;
AdjustWindowRect(&rect, WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
(parent ? WS_CHILD : WS_OVERLAPPEDWINDOW),
FALSE);
if(rect.left < 0) {
*x = 0;
} else {
*x = rect.left;
}
if(rect.top < 0) {
*y = 0;
} else {
*y = rect.top;
}
*width = rect.right - rect.left;
*height = rect.bottom - rect.top;
}