www.pudn.com > 3dgprsrc.rar > HARDWARE.H


#if defined(_CI_) 
 #error This hardware interface can handle RGB only. 
#endif 
#if (defined(_RGB_) && defined(_8BPP_)) 
 #error This hardware interface cannot handle _RGB_ at _8BPP_. 
#endif 
#if ((!defined(_MONO_)) || defined(_STEREO_)) 
 #error This hardware interface can handle just _MONO_. 
#endif 
#if !defined(_HARDWARE_H_) 
#define _HARDWARE_H_ 
 
/** 3DGPL *************************************************\ 
 * (WIN32, 386+, 8/16bit deep modes, 32bit compilers)     * 
 * Header for hardware specific stuff.                    * 
 *                                                        * 
 * Ifdefs:                                                * 
 *  _CI_                    Colour/Intensity model;       * 
 *  _RGB_                   RGB model;                    * 
 *  _8BPP_                  8 bit per pixel maps;         * 
 *  _16BPP_                 16 bit per pixel maps;        * 
 *  _32BPP_                 32 bit per pixel maps;        * 
 *  _MONO_                  Regular image.                * 
 *                                                        * 
 * Files:                                                 * 
 *  hardware.c              Hardware specific stuff.      * 
 *                                                        * 
 * (c) 1995-98 Sergei Savchenko, (savs@cs.mcgill.ca)      * 
\**********************************************************/ 
 
#include <windows.h>                        /* all the MS stuff */ 
#include <string.h>                         /* memset memcpy */ 
#define main _main                          /* to accomodate windows */ 
 
#define HW_set_char(dst,lng,val)  memset(dst,val,lng) 
#define HW_copy_char(src,dst,lng) memcpy(dst,src,lng) 
 
void HW_set_int(int *dst,long lng,int val); 
#define HW_copy_int(src,dst,lng)  memcpy(dst,src,lng*sizeof(int)) 
 
typedef char HW_8_bit;                      /* compiler/mashine independent */ 
#define HW_set_8_bit(dst,lng,val) HW_set_char(dst,lng,val) 
#define HW_copy_8_bit(src,dst,lng) HW_copy_char(src,dst,lng) 
 
typedef short HW_16_bit; 
void HW_set_16_bit(HW_16_bit *dst,long lng,HW_16_bit val); 
#define HW_copy_16_bit(src,dst,lng) memcpy(dst,src,lng*sizeof(HW_16_bit)) 
 
typedef int HW_32_bit; 
#define HW_set_32_bit(dst,lng,val) HW_set_int(dst,lng,val) 
#define HW_copy_32_bit(src,dst,lng) HW_copy_int(src,dst,lng) 
 
#if defined(_16BPP_) 
typedef HW_16_bit HW_pixel; 
#define HW_set_pixel(dst,lng,val) HW_set_16_bit(dst,lng,val) 
#define HW_copy_pixel(src,dst,lng) HW_copy_16_bit(src,dst,lng) 
#endif 
#if defined(_32BPP_) 
typedef HW_32_bit HW_pixel; 
#define HW_set_pixel(dst,lng,val) HW_set_32_bit(dst,lng,val) 
#define HW_copy_pixel(src,dst,lng) HW_copy_32_bit(src,dst,lng) 
#endif 
 
#define HW_SCREEN_X_SIZE 300 
#define HW_SCREEN_Y_SIZE 300                /* number of pixels total */ 
#if defined(_MONO_) 
 #define HW_SCREEN_LINE_SIZE HW_SCREEN_X_SIZE 
#endif 
#define HW_SCREEN_X_MAX    (HW_SCREEN_X_SIZE-1) 
#define HW_SCREEN_Y_MAX    (HW_SCREEN_Y_SIZE-1) 
#define HW_SCREEN_X_CENTRE (HW_SCREEN_X_SIZE/2) 
#define HW_SCREEN_Y_CENTRE (HW_SCREEN_Y_SIZE/2) 
 
#define HW_KEY_ARROW_LEFT  VK_LEFT 
#define HW_KEY_ARROW_RIGHT VK_RIGHT 
#define HW_KEY_ARROW_UP    VK_UP 
#define HW_KEY_ARROW_DOWN  VK_DOWN 
#define HW_KEY_PLUS        VK_ADD 
#define HW_KEY_MINUS       VK_SUBTRACT 
#define HW_KEY_ENTER       VK_RETURN 
#define HW_KEY_SPACE       VK_SPACE 
#define HW_KEY_TAB         VK_TAB           /* all i can think of */ 
 
void HW_init_screen(char *display_name, 
                    char *screen_name 
                   ); 
void HW_blit(void); 
void HW_close_screen(void); 
void HW_init_event_loop(void (*application_main)(void), 
                        void (*application_key_handler)(int key_code) 
                       ); 
void HW_error(char *s,...); 
void HW_close_event_loop(void); 
 
/**********************************************************/ 
 
#endif