Click here to Skip to main content
15,880,796 members
Articles / Multimedia / DirectX

A DirectX Wrapper

Rate me:
Please Sign up or sign in to vote.
4.69/5 (20 votes)
18 Jul 200333 min read 180.9K   4.3K   66  
A DirectX Wrapper
#ifndef __COMMON_H_
#define __COMMON_H_

#define RADIUS		100
#define PI			3.14159265358

#define RECT_WIDTH	5

#define RAD2DEG(x)  ((180.0 * (x))/PI)
#define DEG2RAD(x)	(((x) * PI)/180.0)
#define TOSCALE(x)	(((x)*RADIUS)/255.0)
#define SCALETOMAX(x) (((x)*255.0)/RADIUS)


#define RED	0
#define GREEN 1
#define BLUE 2


#define BAD_SLOPE	1000000.0


struct HSVType;

struct RGBType
{
	COLORREF color() { return RGB(r,g,b); };
	HSVType toHSV();
	int r,g,b;
};

struct HSVType
{
	RGBType toRGB();
	int h,s,v;
};

struct LineDesc
{
	double x,y;
	double slope;
	double c;
};


int Distance(CPoint pt1,CPoint pt2);
CPoint PointOnLine(CPoint pt1,CPoint p2,int len,int maxlen);
double Slope(CPoint pt1,CPoint pt2);
double FindC(LineDesc& l); 
CPoint Intersection(LineDesc desc1,LineDesc desc2);
double AngleFromPoint(CPoint pt,CPoint center);
CPoint PtFromAngle(double angle,double sat,CPoint center);



#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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
Canada Canada
Professional Programmer living in Beautiful Vancouver, BC, Canada.

Comments and Discussions