📄 newgal.h
字号:
/*** $Id: newgal.h,v 1.18 2003/08/12 07:46:18 weiym Exp $** ** newgal.h: the head file of New Graphics Abstraction Layer.** ** Copyright (C) 2003 Feynman Software.** Copyright (C) 2001 ~ 2002 Wei Yongming** ** Note: The architechture of new GAL is borrowed from SDL.** Thank Sam Lantinga and many others for their great work,** and having the same license with MiniGUI.** ** SDL - Simple DirectMedia Layer** Copyright (C) 1997 ~ 2001 Sam Lantinga (slouken@devolution.com)** ** Created date: 2001/10/03*/#ifndef GUI_NEWGAL_H #define GUI_NEWGAL_H#include "gdi.h"#ifdef __cplusplusextern "C" {#endif /* __cplusplus */#define DISABLE_THREADS#define GAL_mutex int#define GAL_bool BOOL#define GAL_TRUE TRUE#define GAL_FALSE FALSE#define GAL_BYTEORDER MGUI_BYTEORDER#define GAL_LIL_ENDIAN MGUI_LIL_ENDIAN#define GAL_BIG_ENDIAN MGUI_BIG_ENDIAN#define GAL_OutOfMemory() fprintf (stderr, "Out of memory")#define GAL_SetError printf#define GAL_ClearError()#define GAL_mutexP(lock) lock++;#define GAL_mutexV(lock) lock--;#define GAL_DestroyMutex(lock) lock=0;/* Transparency definitions: These define alpha as the opacity of a surface */#define GAL_ALPHA_OPAQUE 255#define GAL_ALPHA_TRANSPARENT 0/* Everything in the pixel format structure is read-only */typedef struct GAL_PixelFormat { GAL_Palette *palette; BOOL DitheredPalette; Uint8 BitsPerPixel; Uint8 BytesPerPixel; Uint8 Rloss; Uint8 Gloss; Uint8 Bloss; Uint8 Aloss; Uint8 Rshift; Uint8 Gshift; Uint8 Bshift; Uint8 Ashift; Uint32 Rmask; Uint32 Gmask; Uint32 Bmask; Uint32 Amask; /* RGB color key information */ gal_pixel colorkey; /* Alpha value information (per-surface alpha) */ gal_uint8 alpha;} GAL_PixelFormat;/* * Allocate a pixel format structure and fill it according to the given info. */GAL_PixelFormat *GAL_AllocFormat (int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);/* * Free a previously allocated format structure */void GAL_FreeFormat(GAL_PixelFormat *format);/* typedef for private surface blitting functions */struct GAL_Surface;typedef int (*GAL_blit)(struct GAL_Surface *src, GAL_Rect *srcrect, struct GAL_Surface *dst, GAL_Rect *dstrect);/* This structure should be treated as read-only, except for 'pixels', which, if not NULL, contains the raw pixel data for the surface.*/typedef struct GAL_Surface { Uint32 flags; /* Read-only */ GAL_PixelFormat *format; /* Read-only */ int w, h; /* Read-only */ Uint32 pitch; /* Read-only */ void *pixels; /* Read-write */ int offset; /* Private */ /* Hardware-specific surface info */ struct private_hwdata *hwdata; /* clipping information */ GAL_Rect clip_rect; /* Read-only */ /* Allow recursive locks */ Uint32 locked; /* Private */ /* info for fast blit mapping to other surfaces */ struct GAL_BlitMap *map; /* Private */ /* format version, bumped at every change to invalidate blit maps */ unsigned int format_version; /* Private */ /* Reference count -- used when freeing surface */ int refcount; /* Read-mostly */} GAL_Surface;#if 0/* The most common video overlay formats. For an explanation of these pixel formats, see: http://www.webartz.com/fourcc/indexyuv.htm For information on the relationship between color spaces, see: http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html */#define GAL_YV12_OVERLAY 0x32315659 /* Planar mode: Y + V + U (3 planes) */#define GAL_IYUV_OVERLAY 0x56555949 /* Planar mode: Y + U + V (3 planes) */#define GAL_YUY2_OVERLAY 0x32595559 /* Packed mode: Y0+U0+Y1+V0 (1 plane) */#define GAL_UYVY_OVERLAY 0x59565955 /* Packed mode: U0+Y0+V0+Y1 (1 plane) */#define GAL_YVYU_OVERLAY 0x55595659 /* Packed mode: Y0+V0+Y1+U0 (1 plane) *//* The YUV hardware video overlay */typedef struct GAL_Overlay { Uint32 format; /* Read-only */ int w, h; /* Read-only */ int planes; /* Read-only */ Uint16 *pitches; /* Read-only */ Uint8 **pixels; /* Read-write */ /* Hardware-specific surface info */ struct private_yuvhwfuncs *hwfuncs; struct private_yuvhwdata *hwdata; /* Special flags */ Uint32 hw_overlay :1; /* Flag: This overlay hardware accelerated? */ Uint32 UnusedBits :31;} GAL_Overlay;#endif/* These are the currently supported flags for the GAL_surface *//* Available for GAL_CreateRGBSurface() or GAL_SetVideoMode() */#define GAL_SWSURFACE MEMDC_FLAG_SWSURFACE /* Surface is in system memory */#define GAL_HWSURFACE MEMDC_FLAG_HWSURFACE /* Surface is in video memory */#define GAL_ASYNCBLIT 0x00000004 /* Use asynchronous blits if possible *//* Available for GAL_SetVideoMode() */#define GAL_ANYFORMAT 0x10000000 /* Allow any video depth/pixel-format */#define GAL_HWPALETTE 0x20000000 /* Surface has exclusive palette */#define GAL_DOUBLEBUF 0x40000000 /* Set up double-buffered video mode */#define GAL_FULLSCREEN 0x80000000 /* Surface is a full screen display *//* Used internally (read-only) */#define GAL_HWACCEL 0x00000100 /* Blit uses hardware acceleration */#define GAL_SRCCOLORKEY MEMDC_FLAG_SRCCOLORKEY /* Blit uses a source color key */#define GAL_RLEACCELOK 0x00002000 /* Private flag */#define GAL_RLEACCEL MEMDC_FLAG_RLEACCEL /* Surface is RLE encoded */#define GAL_SRCALPHA MEMDC_FLAG_SRCALPHA /* Blit uses source alpha blending */#define GAL_PREALLOC 0x01000000 /* Surface uses preallocated memory *//* Evaluates to true if the surface needs to be locked before access */#define GAL_MUSTLOCK(surface) \ (surface->offset || \ ((surface->flags & (GAL_HWSURFACE|GAL_ASYNCBLIT|GAL_RLEACCEL)) != 0))/* Useful for determining the video hardware capabilities */typedef struct { Uint32 hw_available :1; /* Flag: Can you create hardware surfaces? */ Uint32 UnusedBits :8; /* Flag: Can you talk to a window manager? */ Uint32 blit_hw :1; /* Flag: Accelerated blits HW --> HW */ Uint32 blit_hw_CC :1; /* Flag: Accelerated blits with Colorkey */ Uint32 blit_hw_A :1; /* Flag: Accelerated blits with Alpha */ Uint32 blit_sw :1; /* Flag: Accelerated blits SW --> HW */ Uint32 blit_sw_CC :1; /* Flag: Accelerated blits with Colorkey */ Uint32 blit_sw_A :1; /* Flag: Accelerated blits with Alpha */ Uint32 blit_fill :1; /* Flag: Accelerated color fill */ Uint32 UnusedBits3 :16; Uint32 video_mem; /* The total amount of video memory (in K) */ GAL_PixelFormat *vfmt; /* Value: The format of the video surface */} GAL_VideoInfo;/* flags for GAL_SetPalette() */#define GAL_LOGPAL 0x01#define GAL_PHYSPAL 0x02/* Function prototypes *//* These functions are used internally, and should not be used unless you * have a specific need to specify the video driver you want to use. * You should normally use GAL_Init() or GAL_InitSubSystem(). * * GAL_VideoInit() initializes the video subsystem -- sets up a connection * to the window manager, etc, and determines the current video mode and * pixel format, but does not initialize a window or graphics mode. * Note that event handling is activated by this routine. * * If you use both sound and video in your application, you need to call * GAL_Init() before opening the sound device, otherwise under Win32 DirectX, * you won't be able to set full-screen display modes. */extern int GAL_VideoInit (const char *driver_name, Uint32 flags);extern void GAL_VideoQuit (void);/* This function fills the given character buffer with the name of the * video driver, and returns a pointer to it if the video driver has * been initialized. It returns NULL if no driver has been initialized. */extern char *GAL_VideoDriverName (char *namebuf, int maxlen);/* * This function returns a pointer to the current display surface. * If GAL is doing format conversion on the display surface, this * function returns the publicly visible surface, not the real video * surface. */extern GAL_Surface * GAL_GetVideoSurface (void);/* * This function returns a read-only pointer to information about the * video hardware. If this is called before GAL_SetVideoMode(), the 'vfmt' * member of the returned structure will contain the pixel format of the * "best" video mode. */extern const GAL_VideoInfo * GAL_GetVideoInfo (void);/* * Check to see if a particular video mode is supported. * It returns 0 if the requested mode is not supported under any bit depth, * or returns the bits-per-pixel of the closest available mode with the * given width and height. If this bits-per-pixel is different from the * one used when setting the video mode, GAL_SetVideoMode() will succeed, * but will emulate the requested bits-per-pixel with a shadow surface. * * The arguments to GAL_VideoModeOK() are the same ones you would pass to * GAL_SetVideoMode() */extern int GAL_VideoModeOK (int width, int height, int bpp, Uint32 flags);/* * Return a pointer to an array of available screen dimensions for the * given format and video flags, sorted largest to smallest. Returns * NULL if there are no dimensions available for a particular format, * or (GAL_Rect **)-1 if any dimension is okay for the given format. * * If 'format' is NULL, the mode list will be for the format given * by GAL_GetVideoInfo()->vfmt */extern GAL_Rect ** GAL_ListModes (GAL_PixelFormat *format, Uint32 flags);/* * Set up a video mode with the specified width, height and bits-per-pixel. * * If 'bpp' is 0, it is treated as the current display bits per pixel. * * If GAL_ANYFORMAT is set in 'flags', the GAL library will try to set the * requested bits-per-pixel, but will return whatever video pixel format is
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -