/*********************************************************
* EGE (Easy Graphics Engine)
* FileName ege.h
* HomePage1 http://misakamm.github.com/xege
* HomePage2 http://misakamm.bitbucket.org/index.htm
* teiba1 http://tieba.baidu.com/f?kw=ege
* teiba2 http://tieba.baidu.com/f?kw=ege%C4%EF
* Blog: http://misakamm.com
* E-Mail: mailto:misakamm[at gmail com]
*
* FileName: ege.h
* 在 VC 下模拟 Borland BGI 绘图库,实现简单的绘图之余,扩展了较复杂的绘图能力
*
* 包含并使用本库时,不要包含conio.h头文件
* 这些头文件不应共存,否则可能会编译错误,
* 或者getch被conio.h内的覆盖(由包含次序决定),请注意
* 如需共存,请使用多文件分开包含的模式使用,
* 即不能一个cpp同时包含,但可以分开包含
* 使用本库,必须用C++编译,可支持的编译器:
* VC6/VC2008/VC2010/VC2012/VC2013/MinGW3.4.5/MinGW4.7.1/MinGW4.8.1
*********************************************************/
/****************************************************************************
** 注意事项:
* ★如果需要显示控制台窗口,请在包含本文件的前面加一行define SHOW_CONSOLE
* ★调用Sleep这个API时,或者调用delay,实际均会转化为调用delay_ms,如必需调用API请使用api_sleep
* ★delay_ms(0)能自行判断有没有更新的必要,连续多次但不大量的调用并不会产生帧率的影响
* ★调用delay_ms, delay_fps, getch, getkey, getmouse 时,窗口内容可能会更新,这些函数相当于内置了delay_ms(0),
* 如果你只需要更新窗口,而不想等待,可以用delay_ms(0)。注意delay只延时而不更新窗口
* ★合理地使用delay_ms/delay_fps函数,可以减少你的程序占用的CPU,否则一个都没有调用同时也没有getch/getmouse的话,程序将占满一个CPU的时间
****************************************************************************/
#ifndef _EGE_H_
#define _EGE_H_
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
#pragma once
#endif
#ifdef _GRAPH_LIB_BUILD_
#ifndef WINVER
#define WINVER 0x0400 // Specifies that the minimum required platform is Windows 95/NT4.
#endif
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400 // Specifies that the minimum required platform is Windows 95/NT4.
#endif
#ifndef _WIN32_WINDOWS
#define _WIN32_WINDOWS 0x0410 // Specifies that the minimum required platform is Windows 98.
#endif
#endif
#ifndef __cplusplus
#error You must use C++ compiler, or you need filename with '.cpp' suffix
#endif
#if defined(_INC_CONIO) || defined(_CONIO_H_)
#error can not include "conio.h" before "graphics.h"
#endif
#if defined(_MSC_VER)
# pragma warning(disable: 4355)
# ifndef _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH
# define _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH
# endif
# ifndef _ALLOW_RUNTIME_LIBRARY_MISMATCH
# define _ALLOW_RUNTIME_LIBRARY_MISMATCH
# endif
#endif
#if !defined(_GRAPH_LIB_BUILD_) && !defined(_GRAPH_NO_LIB_)
# ifdef _MSC_VER
# ifdef _WIN64 // 64 bit libs
# if (_MSC_VER >= 1923)
# pragma comment(lib,"graphics1964.lib")
# elif (_MSC_VER >= 1910)
# pragma comment(lib,"graphics1764.lib")
# elif (_MSC_VER >= 1900)
# pragma comment(lib,"graphics1564.lib")
# elif (_MSC_VER >= 1800)
# pragma comment(lib,"graphics1364.lib")
# elif (_MSC_VER >= 1700)
# pragma comment(lib,"graphics1264.lib")
# elif (_MSC_VER >= 1600)
# pragma comment(lib,"graphics1064.lib")
# elif (_MSC_VER >= 1500)
# pragma comment(lib,"graphics0864.lib")
# elif (_MSC_VER > 1200)
# pragma comment(lib,"graphics05.lib")
# else
# pragma comment(lib,"graphics.lib")
# endif
# else // 32 bit libs
# if (_MSC_VER >= 1923)
# pragma comment(lib,"graphics19.lib")
# elif (_MSC_VER >= 1910)
# pragma comment(lib,"graphics17.lib")
# elif (_MSC_VER >= 1900)
# pragma comment(lib,"graphics15.lib")
# elif (_MSC_VER >= 1800)
# pragma comment(lib,"graphics13.lib")
# elif (_MSC_VER >= 1700)
# pragma comment(lib,"graphics12.lib")
# elif (_MSC_VER >= 1600)
# pragma comment(lib,"graphics10.lib")
# elif (_MSC_VER >= 1500)
# pragma comment(lib,"graphics08.lib")
# elif (_MSC_VER > 1200)
# pragma comment(lib,"graphics05.lib")
# else
# pragma comment(lib,"graphics.lib")
# endif
# endif
# endif
#endif
#if !defined(_GRAPH_LIB_BUILD_) && !defined(_GRAPH_NO_LIB_)
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#ifndef _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE
#endif
#ifndef _CRT_NON_CONFORMING_SWPRINTFS
#define _CRT_NON_CONFORMING_SWPRINTFS
#endif
#endif
#include "windows.h"
#if defined(_MSC_VER) && _MSC_VER <= 1200 && !defined(SetWindowLongPtr)
# define SetWindowLongPtrW SetWindowLongW
# define GetWindowLongPtrW GetWindowLongW
# define GWLP_USERDATA GWL_USERDATA
# define GWLP_WNDPROC GWL_WNDPROC
#endif
#if !defined(_GRAPH_LIB_BUILD_) && !defined(_GRAPH_NO_LIB_)
#if defined(_MSC_VER) && _MSC_VER > 1200
//# pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' ""version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif
#ifndef WM_MOUSEWHEEL
#define WM_MOUSEWHEEL 0x020A
#endif
#ifdef _GRAPH_LIB_BUILD_
#include <cstdio>
#endif
#ifndef _Cdecl
# if __STDC__
# define _Cdecl __cdecl
# else
# define _Cdecl __cdecl
# endif
#endif
#ifdef _MSC_VER
# if defined(_WIN64)
# define EGEAPI
# else
# define EGEAPI _Cdecl
# endif
#else
# if defined(__WORDSIZE)
# if __WORDSIZE > 32
# define EGEAPI
# else
# define EGEAPI _Cdecl
# endif
# else
# define EGEAPI
# endif
#endif
#ifdef _GRAPH_LIB_BUILD_
# define EGE_DEPRECATE(text)
#else
# ifdef _MSC_VER
# ifdef _CRT_DEPRECATE_TEXT
# define EGE_DEPRECATE(text) _CRT_DEPRECATE_TEXT("This function is deprecated, more info visit http://tcgraphics.sourceforge.net/")
# else
# define EGE_DEPRECATE(text)
# endif
# else
# define EGE_DEPRECATE(text) __attribute__((deprecated))
# endif
#endif
#define SHOWCONSOLE 1 // 进入图形模式时,保留控制台的显示
#define RGBTOBGR(color) ((((color) & 0xFF) << 16) | (((color) & 0xFF0000) >> 16) | ((color) & 0xFF00FF00))
#define EGERGB(r, g, b) ( ((r)<<16) | ((g)<<8) | (b))
#define EGERGBA(r, g, b, a) ( ((r)<<16) | ((g)<<8) | (b) | ((a)<<24) )
#define EGEARGB(a, r, g, b) ( ((r)<<16) | ((g)<<8) | (b) | ((a)<<24) )
#define EGEACOLOR(a, color) ( ((color) & 0xFFFFFF) | ((a)<<24) )
#define EGECOLORA(color, a) ( ((color) & 0xFFFFFF) | ((a)<<24) )
#define EGEGET_R(c) ( ((c)>>16) & 0xFF )
#define EGEGET_G(c) ( ((c)>> 8) & 0xFF )
#define EGEGET_B(c) ( ((c)) & 0xFF )
#define EGEGET_A(c) ( ((c)>>24) & 0xFF )
#define EGEGRAY(gray) ( ((gray)<<16) | ((gray)<<8) | (gray))
#define EGEGRAYA(gray, a) ( ((gray)<<16) | ((gray)<<8) | (gray) | ((a)<<24) )
#define EGEAGRAY(a, gray) ( ((gray)<<16) | ((gray)<<8) | (gray) | ((a)<<24) )
#define NAMESPACE_EGE_L namespace ege {
#define NAMESPACE_EGE_R }
NAMESPACE_EGE_L
const double PI = 3.1415926535897932384626;
enum graphics_drivers { /* define graphics drivers */
DETECT, /* requests autodetection */
CGA, MCGA, EGA, EGA64, EGAMONO, IBM8514,/* 1 - 6 */
HERCMONO, ATT400, VGA, PC3270, /* 7 - 10 */
TRUECOLOR, TRUECOLORSIZE,
CURRENT_DRIVER = -1
};
enum graphics_modes { /* graphics modes for each driver */
CGAC0 = 0, /* 320x200 palette 0; 1 page */
CGAC1 = 1, /* 320x200 palette 1; 1 page */
CGAC2 = 2, /* 320x200 palette 2: 1 page */
CGAC3 = 3, /* 320x200 palette 3; 1 page */
CGAHI = 4, /* 640x200 1 page */
MCGAC0 = 0, /* 320x200 palette 0; 1 page */
MCGAC1 = 1, /* 320x200 palette 1; 1 page */
MCGAC2 = 2, /* 320x200 palette 2; 1 page */
MCGAC3 = 3, /* 320x200 palette 3; 1 page */
MCGAMED = 4, /* 640x200 1 page */
MCGAHI = 5, /* 640x480 1 page */
EGALO = 0, /* 640x200 16 color 4 pages */
EGAHI = 1, /* 640x350 16 color 2 pages */
EGA64LO = 0, /* 640x200 16 color 1 page */
EGA64HI = 1, /* 640x350 4 color 1 page */
EGA
评论0
最新资源