/*
 *  ofMain.h
 *  ofxOpenCV
 *
 *  Created by palimpseste on 21/05/11.
 *  Copyright 2011 net.ubaa. All rights reserved.
 *
 */


#pragma once


// PREFER include/exclude method+field only for OF while compiling
// GL
#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64
	#include <GL/glu.h>
	#ifndef GL_BGR
		#define GL_BGR 0x80E0
	#endif
#elif defined __APPLE__
	#include <OpenGL/glu.h>
#else
	#include "GL/glu.h"
#endif










#include <string>
#include <iostream>
#include <stdio.h>
#include <unistd.h>




// namespace
using namespace std;




struct ofPoint
{
	float x;
	float y;
	float z;
	
	ofPoint() {};
	ofPoint( float _x, float _y ) { x = _x; y = _y; z=0;  }

};

struct ofRectangle
{
	float x;
	float y;
	float width;
	float height;
	
	ofRectangle() {};
	ofRectangle( float _x, float _y, float _w, float _h ) { x = _x; y = _y; width = _w; height = _h; }
};








// -------------------------------------------------------------------------------------------------
	#pragma mark log
// -------------------------------------------------------------------------------------------------


enum logLevel
{
	OF_LOG_VERBOSE,
	OF_LOG_WARNING,
	OF_LOG_ERROR
};



inline void ofLog( int level, const char* format, ... )
{
	
	/*va_list args;
	char log[1024];
	
	
	va_start( args, format );
	vsprintf( log, format, args );
	string message = string(log);
	
	switch( level ) {
		case OF_LOG_WARNING : cout << "WARNING: " << message << endl; break;
		case OF_LOG_ERROR	: cerr << "\nERROR: " << message << endl; break;
	}
	
	va_end( args );*/
}






// -------------------------------------------------------------------------------------------------
	#pragma mark utils
// -------------------------------------------------------------------------------------------------

inline float ofClamp( float value, float min, float max )
{
	return value < min ? min : value > max ? max : value;
}

// in this addons clamp is always true
inline float ofMap( float value, float inmin, float inmax, float outmin, float outmax, bool clamp ) 
{
	return ofClamp( (value-inmin) / (inmax-inmin) * (outmax-outmin) + outmin, outmin, outmax );
}
