Click here to Skip to main content
15,888,610 members
Articles / Desktop Programming / Win32

Simple OpenGL Framework

Rate me:
Please Sign up or sign in to vote.
4.46/5 (10 votes)
25 Apr 2012CPOL20 min read 66K   440   40  
GLW is a simple, compact, drop-in framework for developing simple OpenGL games and demos. Its focus is ease of use, platform abstraction and small footprint.
#ifndef etimer_h
#define etimer_h

/*
  ETimer api by Intel; see: http://software.intel.com/en-us/articles/measure-code-sections-using-the-enhanced-timer/
  Licence see: http://software.intel.com/en-us/articles/code-samples-license-2/?target=http://www.intel.com/cd/ids/developer/asmo-na/eng/282380.htm
  If you get any idea of what is says, tell me if I am violating it.
 */

#ifdef __cplusplus
    extern "C" {
#endif

#define CANNOT_GET_FREQUENCY						1
#define CANNOT_GET_START_TIME						2
#define CANNOT_GET_STOP_TIME						3
#define NO_PROCESSOR_AVAILABLE_TO_GET_START_TIME	4
#define NO_PROCESSOR_AVAILABLE_TO_GET_STOP_TIME		5
#define STOP_TIME_TAKEN_ON_DIFFERENT_PROCESSOR		6

#define CANNOT_READ_CLOCK_RESOLUTION				700
#define CANNOT_SET_CLOCK_RESOLUTION					701
#define CLOCK_RESOLUTION_NOT_PREVIOUSLY_SET			702

typedef struct Etime_type etimer;

struct Etime_type
{
	double		Start,
				Stop,
				Frequency;

	DWORD		ProcessorMask;

	BOOL		AlreadyStart;

	int			ErrorFlag;



};

BOOL  etime(etimer *);

BOOL  etimeFrequency(etimer *);

BOOL  etimeInitialize(etimer *);

ULONGLONG  etimeDurationInTicks(etimer *);

double  etimeDurationInSeconds(etimer *);

int  etimeError(etimer *);

void  etimeReset(etimer *);

/* special to change system clock resolution, not in intel etimer */

/**
	
	This function will try to set system resolution to required. It
	should be in acceptable range (for windows nt 1 ~ 15 milliseconds).

	If it succeeds the return value is new resolution, otherwize,
	CANNOT_SET_CLOCK_RESOLUTION error is returned.

	Observe that even if this function succseeds you have not guarantee
	that your timer, thread or whatever will run certain number of times,
	or in certain intervall. Windows is *not* a real time system and does
	not make any such guarantee. It will do best it can to serve your 
	requesst, but there can always be other more important tasks to do.

 */
long unsigned  setSystemClockResolution(unsigned milli);

/**
	This function will try to reverse system clock as before call to set 
	function. If call to set wasn't maid it returns CLOCK_RESOLUTION_NOT_PREVIOUSLY_SET
	error, otherwise new resolution is returned.

	This function should always be called from your program if you have
	used any other of two system apis. This in order to clean up references
	to loaded kernel dll. (System will clean up after us, but be nice ... )

 */
long unsigned  resetSystemClockResolution();

/** This function simply returns current system clock resolution.
	If it for some reason cannot read system clock
	CANNOT_READ_CLOCK_RESOLUTION error is returned. If it succeeds,
	the resolution in nanoseconds is returned. Thus you get resolution
	as both nano and milli seconds.
 */
long unsigned  getSystemClockResolution(double *resolution);



#ifdef __cplusplus
	}
#endif

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Unknown
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions