Initial revisions.
This commit is contained in:
commit
1e94128bbd
4 changed files with 270 additions and 0 deletions
15
Makefile.am
Normal file
15
Makefile.am
Normal file
|
@ -0,0 +1,15 @@
|
|||
if HAVE_DAYLIGHT
|
||||
DEFS += -DHAVE_DAYLIGHT
|
||||
endif
|
||||
|
||||
if HAVE_TIMEZONE
|
||||
DEFS += -DHAVE_TIMEZONE
|
||||
endif
|
||||
|
||||
bin_PROGRAMS = est-epsilon gl-info test-mktime
|
||||
|
||||
est_epsilon_SOURCES = est-epsilon.c
|
||||
|
||||
gl_info_SOURCES = gl-info.c
|
||||
|
||||
test_mktime_SOURCES = test-mktime.cxx
|
20
est-epsilon.c
Normal file
20
est-epsilon.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include <stdio.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
int main() {
|
||||
GLfloat a, t;
|
||||
|
||||
a = 1.0;
|
||||
|
||||
do {
|
||||
printf("a = %.10f\n", a);
|
||||
a = a / 2.0;
|
||||
t = 1.0 + a;
|
||||
} while ( t > 1.0 );
|
||||
|
||||
a = a + a;
|
||||
|
||||
printf("Estimated GLfloat epsilon = %.10f\n", a);
|
||||
|
||||
return(0);
|
||||
}
|
98
gl-info.c
Normal file
98
gl-info.c
Normal file
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
From: Steve Baker <sbaker@link.com>
|
||||
Sender: root@fatcity.com
|
||||
To: OPENGL-GAMEDEV-L <OPENGL-GAMEDEV-L@fatcity.com>
|
||||
Subject: Re: Win32 OpenGL Resource Page
|
||||
Date: Fri, 24 Apr 1998 07:33:51 -0800
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
void getPrints ( GLenum token, char *string )
|
||||
{
|
||||
printf ( "%s = \"%s\"\n", string, glGetString ( token ) ) ;
|
||||
}
|
||||
|
||||
void getPrint2f ( GLenum token, char *string )
|
||||
{
|
||||
GLfloat f[2] ;
|
||||
glGetFloatv ( token, f ) ;
|
||||
printf ( "%s = %g,%g\n", string, f[0],f[1] ) ;
|
||||
}
|
||||
|
||||
void getPrintf ( GLenum token, char *string )
|
||||
{
|
||||
GLfloat f ;
|
||||
glGetFloatv ( token, &f ) ;
|
||||
printf ( "%s = %g\n", string, f ) ;
|
||||
}
|
||||
|
||||
void getPrint2i ( GLenum token, char *string )
|
||||
{
|
||||
GLint i[2] ;
|
||||
glGetIntegerv ( token, i ) ;
|
||||
printf ( "%s = %d,%d\n", string, i[0],i[1] ) ;
|
||||
}
|
||||
|
||||
void getPrinti ( GLenum token, char *string )
|
||||
{
|
||||
GLint i ;
|
||||
glGetIntegerv ( token, &i ) ;
|
||||
printf ( "%s = %d\n", string, i ) ;
|
||||
}
|
||||
|
||||
int main ( int argc, char **argv )
|
||||
{
|
||||
glutInit ( &argc, argv ) ;
|
||||
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;
|
||||
glutCreateWindow ( "You should never see this window!" ) ;
|
||||
|
||||
getPrints ( GL_VENDOR , "GL_VENDOR" ) ;
|
||||
getPrints ( GL_RENDERER , "GL_RENDERER" ) ;
|
||||
getPrints ( GL_VERSION , "GL_VERSION" ) ;
|
||||
getPrints ( GL_EXTENSIONS , "GL_EXTENSIONS" ) ;
|
||||
|
||||
getPrinti ( GL_RED_BITS , "GL_RED_BITS" ) ;
|
||||
getPrinti ( GL_GREEN_BITS , "GL_GREEN_BITS" ) ;
|
||||
getPrinti ( GL_BLUE_BITS , "GL_BLUE_BITS" ) ;
|
||||
getPrinti ( GL_ALPHA_BITS , "GL_ALPHA_BITS" ) ;
|
||||
getPrinti ( GL_DEPTH_BITS , "GL_DEPTH_BITS" ) ;
|
||||
getPrinti ( GL_INDEX_BITS , "GL_INDEX_BITS" ) ;
|
||||
getPrinti ( GL_STENCIL_BITS, "GL_STENCIL_BITS" ) ;
|
||||
|
||||
getPrinti ( GL_ACCUM_RED_BITS , "GL_ACCUM_RED_BITS" ) ;
|
||||
getPrinti ( GL_ACCUM_GREEN_BITS, "GL_ACCUM_GREEN_BITS" ) ;
|
||||
getPrinti ( GL_ACCUM_BLUE_BITS , "GL_ACCUM_BLUE_BITS" ) ;
|
||||
getPrinti ( GL_ACCUM_ALPHA_BITS, "GL_ACCUM_ALPHA_BITS" ) ;
|
||||
|
||||
getPrinti ( GL_AUX_BUFFERS, "GL_AUX_BUFFERS" ) ;
|
||||
|
||||
getPrinti ( GL_MAX_ATTRIB_STACK_DEPTH , "GL_MAX_ATTRIB_STACK_DEPTH" ) ;
|
||||
getPrinti ( GL_MAX_NAME_STACK_DEPTH , "GL_MAX_NAME_STACK_DEPTH" ) ;
|
||||
getPrinti ( GL_MAX_TEXTURE_STACK_DEPTH , "GL_MAX_TEXTURE_STACK_DEPTH" ) ;
|
||||
getPrinti ( GL_MAX_PROJECTION_STACK_DEPTH, "GL_MAX_PROJECTION_STACK_DEPTH" ) ;
|
||||
getPrinti ( GL_MAX_MODELVIEW_STACK_DEPTH , "GL_MAX_MODELVIEW_STACK_DEPTH" ) ;
|
||||
|
||||
getPrinti ( GL_MAX_CLIP_PLANES , "GL_MAX_CLIP_PLANES" ) ;
|
||||
getPrinti ( GL_MAX_EVAL_ORDER , "GL_MAX_EVAL_ORDER" ) ;
|
||||
getPrinti ( GL_MAX_LIGHTS , "GL_MAX_LIGHTS" ) ;
|
||||
getPrinti ( GL_MAX_LIST_NESTING , "GL_MAX_LIST_NESTING" ) ;
|
||||
getPrinti ( GL_MAX_TEXTURE_SIZE , "GL_MAX_TEXTURE_SIZE" ) ;
|
||||
getPrint2i( GL_MAX_VIEWPORT_DIMS , "GL_MAX_VIEWPORT_DIMS" ) ;
|
||||
|
||||
getPrintf ( GL_POINT_SIZE_GRANULARITY, "GL_POINT_SIZE_GRANULARITY" ) ;
|
||||
getPrint2f( GL_POINT_SIZE_RANGE , "GL_POINT_SIZE_RANGE" ) ;
|
||||
|
||||
return 0 ;
|
||||
}
|
137
test-mktime.cxx
Normal file
137
test-mktime.cxx
Normal file
|
@ -0,0 +1,137 @@
|
|||
// test the systems mktime() function
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef HAVE_SYS_TIMEB_H
|
||||
# include <sys/types.h>
|
||||
# include <sys/timeb.h> // for ftime() and struct timeb
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h> // for gettimeofday()
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h> // for get/setitimer, gettimeofday, struct timeval
|
||||
#endif
|
||||
|
||||
#define LST_MAGIC_TIME_1998 890481600
|
||||
|
||||
|
||||
// Fix up timezone if using ftime()
|
||||
long int fix_up_timezone( long int timezone_orig ) {
|
||||
#if !defined( HAVE_GETTIMEOFDAY ) && defined( HAVE_FTIME )
|
||||
// ftime() needs a little extra help finding the current timezone
|
||||
struct timeb current;
|
||||
ftime(¤t);
|
||||
return( current.timezone * 60 );
|
||||
#else
|
||||
return( timezone_orig );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// Return time_t for Sat Mar 21 12:00:00 GMT
|
||||
//
|
||||
// I believe the mktime() has a SYSV vs. BSD behavior difference.
|
||||
//
|
||||
// The BSD style mktime() is nice because it returns its result
|
||||
// assuming you have specified the input time in GMT
|
||||
//
|
||||
// The SYSV style mktime() is a pain because it returns its result
|
||||
// assuming you have specified the input time in your local timezone.
|
||||
// Therefore you have to go to extra trouble to convert back to GMT.
|
||||
//
|
||||
// If you are having problems with incorrectly positioned astronomical
|
||||
// bodies, this is a really good place to start looking.
|
||||
|
||||
time_t get_start_gmt(int year) {
|
||||
struct tm mt;
|
||||
|
||||
// For now we assume that if daylight is not defined in
|
||||
// /usr/include/time.h that we have a machine with a BSD behaving
|
||||
// mktime()
|
||||
# if !defined(HAVE_DAYLIGHT)
|
||||
# define MK_TIME_IS_GMT 1
|
||||
# endif
|
||||
|
||||
// timezone seems to work as a proper offset for Linux & Solaris
|
||||
# if defined( __linux__ ) || defined( __sun__ )
|
||||
# define TIMEZONE_OFFSET_WORKS 1
|
||||
# endif
|
||||
|
||||
mt.tm_mon = 2;
|
||||
mt.tm_mday = 21;
|
||||
mt.tm_year = year;
|
||||
mt.tm_hour = 12;
|
||||
mt.tm_min = 0;
|
||||
mt.tm_sec = 0;
|
||||
mt.tm_isdst = -1; // let the system determine the proper time zone
|
||||
|
||||
# if defined( MK_TIME_IS_GMT )
|
||||
return ( mktime(&mt) );
|
||||
# else // ! defined ( MK_TIME_IS_GMT )
|
||||
|
||||
long int start = mktime(&mt);
|
||||
|
||||
printf("start1 = %ld\n", start);
|
||||
printf("start2 = %s", ctime(&start));
|
||||
printf("(tm_isdst = %d)\n", mt.tm_isdst);
|
||||
|
||||
timezone = fix_up_timezone( timezone );
|
||||
|
||||
# if defined( TIMEZONE_OFFSET_WORKS )
|
||||
printf("start = %ld, timezone = %ld\n", start, timezone);
|
||||
return( start - timezone );
|
||||
# else // ! defined( TIMEZONE_OFFSET_WORKS )
|
||||
|
||||
daylight = mt.tm_isdst;
|
||||
if ( daylight > 0 ) {
|
||||
daylight = 1;
|
||||
} else if ( daylight < 0 ) {
|
||||
printf("OOOPS, problem in fg_time.cxx, no daylight savings info.\n");
|
||||
}
|
||||
|
||||
long int offset = -(timezone / 3600 - daylight);
|
||||
|
||||
printf(" Raw time zone offset = %ld\n", timezone);
|
||||
printf(" Daylight Savings = %d\n", daylight);
|
||||
printf(" Local hours from GMT = %ld\n", offset);
|
||||
|
||||
long int start_gmt = start - timezone + (daylight * 3600);
|
||||
|
||||
printf(" March 21 noon (CST) = %ld\n", start);
|
||||
|
||||
return ( start_gmt );
|
||||
# endif // ! defined( TIMEZONE_OFFSET_WORKS )
|
||||
# endif // ! defined ( MK_TIME_IS_GMT )
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
time_t start_gmt;
|
||||
|
||||
start_gmt = get_start_gmt(98);
|
||||
|
||||
|
||||
if ( start_gmt == LST_MAGIC_TIME_1998 ) {
|
||||
#ifdef MK_TIME_IS_GMT
|
||||
printf("mktime() assumes GMT on your system, lucky you!\n");
|
||||
#else
|
||||
printf("mktime() assumes local time zone on your system, but we can\n");
|
||||
printf("compensate just fine.\n");
|
||||
#endif
|
||||
} else {
|
||||
printf("There is likely a problem with mktime() on your system.\n");
|
||||
printf("This will cause the sun/moon/stars/planets to be in the\n");
|
||||
printf("wrong place in the sky and the rendered time of day will be\n");
|
||||
printf("incorrect.\n\n");
|
||||
printf("Please report this to curt@me.umn.edu so we can work to fix\n");
|
||||
printf("the problem on your platform.\n");
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue