Descent3/lib/Ddgr.h

249 lines
8.2 KiB
C
Raw Normal View History

2024-04-16 03:43:29 +00:00
/*
* $Logfile: /DescentIII/Main/lib/Ddgr.h $
* $Revision: 6 $
* $Date: 12/23/97 6:16p $
* $Author: Samir $
*
* DDGR library interface header
*
* $Log: /DescentIII/Main/lib/Ddgr.h $
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 6 12/23/97 6:16p Samir
* Moved ddgr_Close to header.
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 5 12/22/97 7:24p Samir
* took out transparent color defs.
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 4 12/22/97 7:13p Samir
* Moved constants to grdefs.h
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 3 9/12/97 4:13p Samir
* Added some private data access functions.
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 1 6/23/97 9:25p Samir
* added because source safe sucks
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 26 6/12/97 6:30p Samir
* DDGR v2.0 Changes in 2d system implemented.
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 25 6/11/97 1:07p Samir
* The removal of gameos and replaced with oeApplication, oeDatabase
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 24 5/22/97 4:03p Samir
* Hacked OpenGL stuff. WILL CHANGE
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 23 5/15/97 2:08p Samir
* Added 8-bit support and driver info structure.
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 22 3/28/97 3:07p Samir
* Clear function now takes a color
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 21 3/27/97 11:11a Samir
* Revised headers to reflect movement of functions from ddgr to 2dlib
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 20 3/26/97 7:44p Samir
* Took out prototypes to unimplemented functions.
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 19 2/27/97 6:16p Samir
* moved high level functions to 2dlib internal library
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 18 2/03/97 6:00p Jason
* added 2d bitmap scaling functions
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 17 1/30/97 6:01p Samir
* The partition of memory and os surfaces as well as the change in
* ddgr_surface structure and all related changes.
*
* $NoKeywords: $
*/
#ifndef _DDGR_H
#define _DDGR_H
#include "pstypes.h"
2024-04-16 18:56:40 +00:00
#include "Macros.h"
2024-04-16 03:43:29 +00:00
#include "grdefs.h"
// ----------------------------------------------------------------------------
2024-04-16 18:56:40 +00:00
// DDGR
2024-04-16 03:43:29 +00:00
// version 1.0 // DirectDraw, GDI support
// version 2.x // fullscreen-windowed remanagement.
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Data structures
// ----------------------------------------------------------------------------
/* Type definitions */
class oeApplication;
2024-04-16 18:56:40 +00:00
/*
Diagnostic DDGR system types and functions
2024-04-16 03:43:29 +00:00
*/
2024-04-16 18:56:40 +00:00
typedef struct ddgr_init_info {
oeApplication *obj; // the app object created by app calling
char *subsystem; // subsystem name (i.e. 'DirectDraw', 'GDI')
ushort windowed : 1; // are we running in a fullscreen or windowed mode
ushort debug : 1; // are we running in debug mode?
} ddgr_init_info;
2024-04-16 03:43:29 +00:00
/* app = application object.
2024-04-16 18:56:40 +00:00
subsystem = subsystem name ('DirectDraw', 'GDI')
fullscreen = whether it's full screen or windowed
2024-04-16 03:43:29 +00:00
*/
bool ddgr_Init(oeApplication *app, char *subsystem, bool fullscreen);
void ddgr_Close();
void ddgr_GetSubsystem(char *name, bool *fullscreen);
// returns aspect ratio of current display.
float ddgr_GetAspectRatio();
/* Surface bit depths
2024-04-16 18:56:40 +00:00
The bitdepth of the surface determines the color format of the surface. Renderers
should use this value to plot
2024-04-16 03:43:29 +00:00
*/
// Green with all 6 bits set to 1 is our transparent color
// default transparent color to 16bit, but all code should use the first 2 defines.
/* Surface types
2024-04-16 18:56:40 +00:00
Surfaces symbolize a flat 2d surface where pixels are lit. Essentially, a surface could
be a bitmap, but if it's the display, it's a bitmap managed by the video card.
The goal of this library is to provide a clean, device-independent method to accessing
surfaces.
SURFTYPE_VIDEOSCREEN:
The video screen is a physical or virtual display.
When you create a videoscreen, you may specify either it is monopage or dualpage (backbuffer)
When dualpage, the program can RENDER to the 1st page. To update the video display, you
must perform a surface flip.
SURFTYPE_GENERIC:
This is a generic bitmap managed by the operating system. RENDERING is allowed.
2024-04-16 03:43:29 +00:00
*/
2024-04-16 18:56:40 +00:00
const int SURFTYPE_VIDEOSCREEN = 1, // This is equivical to the display.
SURFTYPE_GENERIC = 2; // This is an offscreen bitmap.
2024-04-16 03:43:29 +00:00
/* Surface flags
2024-04-16 18:56:40 +00:00
Flags modify a surfaces behavior. A surface may have a backbuffer, which is only really
useful for videoscreens.
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
SURFFLAG_BACKBUFFER:
This surface has a backbuffer.
v2.0 Supported in only videoscreen surfaces.
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
SURFFLAG_COLORKEY:
This surface was created with colorkeying in mind.
Renderers should keep this in mind, and check this flag.
2024-04-16 03:43:29 +00:00
*/
2024-04-16 18:56:40 +00:00
const int SURFFLAG_BACKBUFFER = 1, SURFFLAG_COLORKEY = 2;
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
/* Surface structures
The surface
2024-04-16 03:43:29 +00:00
*/
2024-04-16 18:56:40 +00:00
const int SURF_NAMELEN = 16;
typedef struct ddgr_surface {
void *obj; // internal structure info to library
char name[SURF_NAMELEN]; // name
int w, h, bpp; // width, height and bit depth
ushort type; // how driver handles this surface
ushort flags; // colorkeying, etc.
int locks; // lock count.
} ddgr_surface;
#if defined(DD_ACCESS_RING) // only available to DD_ACCESS libraries.
2024-04-16 03:43:29 +00:00
#if defined(WIN32)
2024-04-16 18:56:40 +00:00
/*
ddraw_surf = true if this is a true DirectDraw surface, false if a GDI surface
object_ptr = DirectDraw object if ddraw_surf = true, a HDC if a GDI surface.
2024-04-16 03:43:29 +00:00
*/
void ddgr_surf_GetPrivateData(ddgr_surface *sf, bool *ddraw_surf, uint *object_ptr);
// you must typecase this return value to LPDIRECTDRAW
unsigned ddgr_GetDDrawObject();
2024-04-16 18:56:40 +00:00
#endif // WIN32
#endif // DD_ACCESS_RING
2024-04-16 03:43:29 +00:00
/* Surface Functions
2024-04-16 18:56:40 +00:00
*/
2024-04-16 03:43:29 +00:00
/* input:
2024-04-16 18:56:40 +00:00
sf->name is optional.
sf->w, sf->h, sf->bpp are mandatory
sf->type and sf->flags are mandatory.
output:
sf->obj = surface object.
sf->locks = 0
2024-04-16 03:43:29 +00:00
*/
2024-04-16 18:56:40 +00:00
bool ddgr_surf_Create(ddgr_surface *sf);
void ddgr_surf_Destroy(ddgr_surface *sf);
2024-04-16 03:43:29 +00:00
/* retrieves a pointer to surface memory. allowed to lock one surface multiple times.
2024-04-16 18:56:40 +00:00
ptr is the returned pointer to surface memory. used to unlock surface also
rowsize is the size in bytes of one row of memory.
2024-04-16 03:43:29 +00:00
*/
2024-04-16 18:56:40 +00:00
bool ddgr_surf_Lock(ddgr_surface *sf, void **ptr, int *rowsize);
bool ddgr_surf_Unlock(ddgr_surface *sf, void *ptr);
2024-04-16 03:43:29 +00:00
// attaches an OS handle to a surface
2024-04-16 18:56:40 +00:00
void ddgr_surf_AttachHandle(ddgr_surface *sf, unsigned handle);
2024-04-16 03:43:29 +00:00
/* initializes a video screen from the given input surface which specifies the dimensions
2024-04-16 18:56:40 +00:00
of the screen.
sf->name is optional
sf->w, sf->h are mandatory
sf->bpp is recommended. if set to BPP_DEFAULT, it uses the current display bit depth
sf->type = SURFTYPE_VIDEOSCREEN
sf->flags = 0 or SURFFLAG_BACKBUFFER. surfaces with backbuffers allow rendering to
them and display via flip. monopage surfaces don't have this luxury.
2024-04-16 03:43:29 +00:00
*/
2024-04-16 18:56:40 +00:00
bool ddgr_surf_InitVideo(ddgr_surface *sf);
2024-04-16 03:43:29 +00:00
/* close video reverses the operation of init video for that surface. the display should stay
2024-04-16 18:56:40 +00:00
the same, but no more operations may occur to that surface through this library.
2024-04-16 03:43:29 +00:00
*/
2024-04-16 18:56:40 +00:00
void ddgr_surf_CloseVideo(ddgr_surface *sf);
2024-04-16 03:43:29 +00:00
/* flips the buffers in a surface. really only useful for video screens
2024-04-16 18:56:40 +00:00
*/
bool ddgr_surf_FlipVideo(ddgr_surface *sf);
2024-04-16 03:43:29 +00:00
/* graphic primatives
2024-04-16 18:56:40 +00:00
*/
2024-04-16 03:43:29 +00:00
void ddgr_surf_Clear(ddgr_surface *dsf, ddgr_color col, int l, int t, int w, int h);
bool ddgr_surf_Blt(ddgr_surface *dsf, int dx, int dy, ddgr_surface *ssf, int sx, int sy, int sw, int sh);
2024-04-16 18:56:40 +00:00
/*
8-bit palette surface structures
2024-04-16 03:43:29 +00:00
*/
2024-04-16 18:56:40 +00:00
typedef struct ddgr_rgb {
ubyte r, g, b; // RGB triplet
ubyte x; // reserved...
} ddgr_rgb;
typedef struct ddgr_palette {
void *obj; // internal object
ddgr_rgb rgb[256]; // rgb values for palette.
} ddgr_palette;
2024-04-16 03:43:29 +00:00
// attaches a palette to an 8-bit surface only.
bool ddgr_surf_AttachPalette(ddgr_surface *surf, ddgr_palette *pal);
// grabs a palette.
bool ddgr_surf_GetPalette(ddgr_surface *surf, ddgr_palette *pal);
// creates and destroys palette objects.
bool ddgr_8bit_CreatePalette(ddgr_palette *pal);
bool ddgr_8bit_DestroyPalette(ddgr_palette *pal);
// loads a palette with specified entriyes
bool ddgr_8bit_LoadPalette(ddgr_palette *pal, int start, int count);
// returns an index into the palette
2024-04-16 18:56:40 +00:00
int ddgr_8bit_FindClosestColor(ddgr_palette *pal, ddgr_color col);
2024-04-16 03:43:29 +00:00
#endif