From afdd0eff822b868ab6d79e4ecb6f01aae9da1cf3 Mon Sep 17 00:00:00 2001 From: Akiko Date: Sun, 7 Jun 2015 15:29:27 +0200 Subject: [PATCH] - proper names for the global includes --- include/BaseType.h | 85 ++++++++++++++++++ include/ErrorLog.h | 238 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/GETypes.h | 140 +++++++++++++++++++++++++++++ include/PixelFormat.h | 152 ++++++++++++++++++++++++++++++++ include/Ram.h | 140 +++++++++++++++++++++++++++++ include/Vec3d.h | 70 +++++++++++++++ include/XForm3d.h | 225 +++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 1050 insertions(+) create mode 100644 include/BaseType.h create mode 100644 include/ErrorLog.h create mode 100644 include/GETypes.h create mode 100644 include/PixelFormat.h create mode 100644 include/Ram.h create mode 100644 include/Vec3d.h create mode 100644 include/XForm3d.h diff --git a/include/BaseType.h b/include/BaseType.h new file mode 100644 index 0000000..d219f53 --- /dev/null +++ b/include/BaseType.h @@ -0,0 +1,85 @@ +/****************************************************************************************/ +/* BASETYPE.H */ +/* */ +/* Author: */ +/* Description: Basic type definitions and calling convention defines */ +/* */ +/* The contents of this file are subject to the Genesis3D Public License */ +/* Version 1.01 (the "License"); you may not use this file except in */ +/* compliance with the License. You may obtain a copy of the License at */ +/* http://www.genesis3d.com */ +/* */ +/* Software distributed under the License is distributed on an "AS IS" */ +/* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */ +/* the License for the specific language governing rights and limitations */ +/* under the License. */ +/* */ +/* The Original Code is Genesis3D, released March 25, 1999. */ +/* Genesis3D Version 1.1 released November 15, 1999 */ +/* Copyright (C) 1999 WildTangent, Inc. All Rights Reserved */ +/* */ +/****************************************************************************************/ +#ifndef GE_BASETYPE_H +#define GE_BASETYPE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/******** The Genesis Calling Conventions ***********/ + +#define GENESISCC _fastcall + +#if defined(BUILDGENESIS) && defined(GENESISDLLVERSION) + #define GENESISAPI _declspec(dllexport) +#else + #if defined(GENESISDLLVERSION) + #define GENESISAPI _declspec(dllimport) + #else + #define GENESISAPI + #endif +#endif + +/******** The Basic Types ****************************/ + +typedef signed int geBoolean; +#define GE_FALSE (0) +#define GE_TRUE (1) + +typedef float geFloat; +typedef double geDouble; + +#ifndef NULL +/* #define NULL ((void *)0) */ +#define NULL 0 +#endif + +typedef signed long int32; +typedef signed short int16; +typedef signed char int8 ; +typedef unsigned long uint32; +typedef unsigned short uint16; +typedef unsigned char uint8 ; + +/******** Macros on Genesis basic types *************/ + +#define GE_ABS(x) ( (x) < 0 ? (-(x)) : (x) ) +#define GE_CLAMP(x,lo,hi) ( (x) < (lo) ? (lo) : ( (x) > (hi) ? (hi) : (x) ) ) +#define GE_CLAMP8(x) GE_CLAMP(x,0,255) +#define GE_CLAMP16(x) GE_CLAMP(x,0,65536) +#define GE_BOOLSAME(x,y) ( ( (x) && (y) ) || ( !(x) && !(y) ) ) + +#define GE_EPSILON ((geFloat)0.000797f) +#define GE_FLOATS_EQUAL(x,y) ( GE_ABS((x) - (y)) < GE_EPSILON ) +#define GE_FLOAT_ISZERO(x) GE_FLOATS_EQUAL(x,0.0f) + +#define GE_PI ((geFloat)3.14159265358979323846f) + +/****************************************************/ + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/include/ErrorLog.h b/include/ErrorLog.h new file mode 100644 index 0000000..5a64ae2 --- /dev/null +++ b/include/ErrorLog.h @@ -0,0 +1,238 @@ +/****************************************************************************************/ +/* ERRORLOG.H */ +/* */ +/* Author: Mike Sandige */ +/* Description: Generic error logging system interface */ +/* */ +/* The contents of this file are subject to the Genesis3D Public License */ +/* Version 1.01 (the "License"); you may not use this file except in */ +/* compliance with the License. You may obtain a copy of the License at */ +/* http://www.genesis3d.com */ +/* */ +/* Software distributed under the License is distributed on an "AS IS" */ +/* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */ +/* the License for the specific language governing rights and limitations */ +/* under the License. */ +/* */ +/* The Original Code is Genesis3D, released March 25, 1999. */ +/* Genesis3D Version 1.1 released November 15, 1999 */ +/* Copyright (C) 1999 WildTangent, Inc. All Rights Reserved */ +/* */ +/****************************************************************************************/ +#ifndef GE_ERRORLOG_H +#define GE_ERRORLOG_H + +#include "BaseType.h" + +#ifndef NDEBUG + #define ERRORLOG_FULL_REPORTING +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum +{ + GE_ERR_INVALID_DRIVER_HANDLE, // Driver not supported + GE_ERR_INVALID_MODE_HANDLE, // Mode not supported + GE_ERR_DRIVER_INIT_FAILED, // Could not init Driver + GE_ERR_DRIVER_ALLREADY_INITIALIZED, // Driver init failure + GE_ERR_DRIVER_NOT_FOUND, // File open error for driver + GE_ERR_DRIVER_NOT_INITIALIZED, // Driver shutdown failure + GE_ERR_INVALID_DRIVER, // Wrong driver version, or bad driver + GE_ERR_DRIVER_BEGIN_SCENE_FAILED, + GE_ERR_DRIVER_END_SCENE_FAILED, + GE_ERR_CREATE_SOUND_MANAGER_FAILED, + GE_ERR_CREATE_SOUND_BUFFER_FAILED, + GE_ERR_DS_ERROR, + GE_ERR_INVALID_WAV, + GE_ERR_NO_PERF_FREQ, + GE_ERR_FILE_OPEN_ERROR, + GE_ERR_FILE_READ_ERROR, + GE_ERR_FILE_WRITE_ERROR, + GE_ERR_PALETTE_LOAD_FAILURE, + GE_ERR_GBSP_LOAD_FAILURE, + GE_ERR_INVALID_PARMS, + GE_ERR_INVALID_CAMERA, + GE_ERR_RENDER_WORLD_FAILED, + GE_ERR_BEGIN_WORLD_FAILED, + GE_ERR_END_WORLD_FAILED, + GE_ERR_BEGIN_MODELS_FAILED, + GE_ERR_END_MODELS_FAILED, + GE_ERR_BEGIN_MESHES_FAILED, + GE_ERR_END_MESHES_FAILED, + GE_ERR_RENDER_MESH_FAILED, + GE_ERR_BAD_LMAP_EXTENTS, + GE_ERR_INVALID_TEXTURE, + GE_ERR_REGISTER_WORLD_TEXTURE_FAILED, + GE_ERR_REGISTER_LIGHTMAPS_FAILED, + GE_ERR_REGISTER_WORLD_PALETTE_FAILED, + GE_ERR_REGISTER_MISC_TEXTURE_FAILED, + GE_ERR_INVALID_MESH_FILE, + GE_ERR_LOAD_BITMAP_FAILED, + GE_ERR_MAX_MESH_DEFS, + GE_ERR_MESH_MAX_NODES, + GE_ERR_INVALID_MESH_MATERIAL, + GE_ERR_MAX_MESH_MATERIALS, + GE_ERR_MAX_MESH_CLIP_PLANES, + GE_ERR_RENDERQ_OVERFLOW, + GE_ERR_INVALID_LTYPE, + GE_ERR_MAX_ENTITIES, + GE_ERR_GET_ENTITY_DATA_ERROR, + GE_ERR_INVALID_ENTITY_FIELD_TYPE, + GE_ERR_MODEL_NOT_FOUND, + GE_ERR_MODEL_NOT_IN_ENTITY, + GE_ERR_MAX_TEXTURES, + GE_ERR_MAX_DECALS, + GE_ERR_MAX_VERTS, + GE_ERR_OUT_OF_MEMORY, + GE_ERR_INVALID_BSP_TAG, + GE_ERR_INVALID_BSP_VERSION, + GE_ERR_ERROR_READING_BSP_CHUNK, + ERR_PATH_CREATE_ENOMEM, // failure to create a path (memory allocation failed) + ERR_PATH_INSERT_R_KEYFRAME, // failure to insert a rotation keyframe + ERR_PATH_INSERT_T_KEYFRAME, // failure to insert a translation keyframe + ERR_PATH_DELETE_R_KEYFRAME, // failure to delete a rotation keyframe + ERR_PATH_DELETE_T_KEYFRAME, // failure to delete a translation keyframe + ERR_PATH_FILE_READ, // failure to read from file + ERR_PATH_FILE_VERSION, // tried to create path from file with wrong/bad version + ERR_PATH_FILE_PARSE, // failure to parse file (unexpected format problem) + ERR_PATH_FILE_WRITE, // failure to read from file + ERR_MOTION_CREATE_ENOMEM, // failure to create (memory allocation failed) + ERR_MOTION_ADDPATH_ENOMEM, // failure to add path into motion (memory allocation failed) + ERR_MOTION_ADDPATH_PATH, // failure to add path into motion (path creation failed) + ERR_MOTION_ADDPATH_BAD_NAME, // failure to add path into motion due to name conflict + ERR_MOTION_INSERT_EVENT, // failure to insert event (memory allocation failed or duplicate key) + ERR_MOTION_DELETE_EVENT, // failure to insert event + ERR_MOTION_FILE_READ, // failure to read from file + ERR_MOTION_FILE_WRITE, // failure to write to file + ERR_MOTION_FILE_PARSE, // failure to parse file (unexpected format problem) + ERR_TKARRAY_INSERT_IDENTICAL, // failure to insert into list because of existing identical key + ERR_TKARRAY_INSERT_ENOMEM, // failure to insert into list because of memory allocation failure + ERR_TKARRAY_DELETE_NOT_FOUND, // failure to delete from list because key was not found + ERR_TKARRAY_CREATE, // failure to create TKArray object (out of memroy) + ERR_TKARRAY_TOO_BIG, // TKArray object can't be added to - it's list is as big as it can get + ERR_VKARRAY_INSERT, // insertion to VKArray failed + ERR_QKARRAY_INSERT, // insertion to QKArray failed + ERR_POSE_CREATE_ENOMEM, // Motion object failed to create (memory allocation failed) + ERR_POSE_ADDJOINT_ENOMEM, // Motion_AddJoint failed to allocate/reallocate memory for new joint + ERR_TKEVENTS_CREATE_ENOMEM, // failure to create TKEvents object (memory allocation failed) + ERR_TKEVENTS_DELETE_NOT_FOUND, // failure to delete from list because key was not found + ERR_TKEVENTS_INSERT_ENOMEM, // failure to insert into list because of memory allocation failure + ERR_TKEVENTS_INSERT, // failure to insert into list + ERR_TKEVENTS_FILE_READ, // failure to read from data file + ERR_TKEVENTS_FILE_WRITE, // failure to write to data file + ERR_TKEVENTS_FILE_VERSION, // failure to read tkevents object: file has wrong version + ERR_TKEVENTS_FILE_PARSE, // failure to parse file (unexpected format problem) + ERR_STRBLOCK_ENOMEM, // failure to create, insert, or append (memory allocation failed) + ERR_STRBLOCK_STRLEN, // string too long to insert or append + ERR_STRBLOCK_FILE_READ, // failure to read from data file + ERR_STRBLOCK_FILE_WRITE, // failure to write to data file + ERR_STRBLOCK_FILE_PARSE, // failure to parse reading from input file (unexpected format problem) + ERR_BODY_ENOMEM, // failure to create, or add (memory allocation failed) + ERR_BODY_FILE_PARSE, // failure to parse reading from input file (unexpected format problem) + ERR_BODY_FILE_READ, // failure to read from data file + ERR_BODY_FILE_WRITE, // failure to write to data file + ERR_BODY_BONEXFARRAY, // XFArray object failed to return array, or array size doesn't match bone count + ERR_XFARRAY_ENOMEM, // failure to create. (memory allocation failure) + ERR_PUPPET_ENOMEM, // failure to create. (memory allocation failure) + ERR_PUPPET_RENDER, // failure to render. + ERR_PUPPET_NO_MATERIALS, // failure to create: associated body has no materials. + ERR_PUPPET_LOAD_TEXTURE, // failure to load texture + ERR_TEXPOOL_ENOMEM, // failure to create or add to. (memory allocation/reallocation failure) + ERR_TEXPOOL_TOO_BIG, // failure to add to pool, pool is too large. + ERR_TEXPOOL_LOAD_TEXTURE, // failure to load texture into pool + ERR_TEXPOOL_TEXTURE_NOT_FREE, // texture pool destroyed without first freeing all it's shared textures + ERR_ACTOR_ENOMEM, // failure to create. (memory allocation failure) + ERR_ACTOR_RENDER_PREP, // failure to prepare actor for rendering (bad Body or allocation failure) + ERR_ACTOR_RENDER_FAILED, // failure to render. failure to get geometry from Body + ERR_ACTOR_TOO_MANY_MOTIONS, // failure to add motion. too many. + ERR_ACTOR_FILE_READ, // failure to read from data file. + ERR_ACTOR_FILE_PARSE, // failure to parse reading from input file(unexpected format problem) + ERR_ACTOR_FILE_WRITE, // failure to write to data file. + GE_ERR_INVALID_MODEL_MOTION_FILE, // Bad model motion file (for bsp files) + GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, // Chunk size does not match structure size of kind +//MRB BEGIN +//geSprite + ERR_SPRITE_ENOMEM, // failure to create. (memory allocation failure) + ERR_SPRITE_INVALIDBITMAP, // failure to use bitmap because bitmap was invalid +//MRB END +} geErrorLog_ErrorIDEnumType; + + +typedef enum +{ + GE_ERR_MEMORY_RESOURCE, + GE_ERR_DISPLAY_RESOURCE, + GE_ERR_SOUND_RESOURCE, + GE_ERR_SYSTEM_RESOURCE, + GE_ERR_INTERNAL_RESOURCE, + + GE_ERR_FILEIO_OPEN, + GE_ERR_FILEIO_CLOSE, + GE_ERR_FILEIO_READ, + GE_ERR_FILEIO_WRITE, + GE_ERR_FILEIO_FORMAT, + GE_ERR_FILEIO_VERSION, + + GE_ERR_LIST_FULL, + GE_ERR_DATA_FORMAT, + GE_ERR_SEARCH_FAILURE, +} geErrorLog_ErrorClassType; + +GENESISAPI void geErrorLog_Clear(void); + // clears error history + +GENESISAPI int geErrorLog_Count(void); + // reports size of current error log + +GENESISAPI void geErrorLog_AddExplicit(geErrorLog_ErrorClassType, + const char *ErrorIDString, + const char *ErrorFileString, + int LineNumber, + const char *UserString, + const char *Context); + // not intended to be used directly: use ErrorLog_Add or ErrorLog_AddString + + +#ifdef ERRORLOG_FULL_REPORTING + // 'Debug' version includes a textual error id, and the user string + + #define geErrorLog_Add(Error, Context) geErrorLog_AddExplicit(Error, #Error, __FILE__, __LINE__,"", Context) + // logs an error. + + #define geErrorLog_AddString(Error,String, Context) geErrorLog_AddExplicit(Error, #Error, __FILE__,__LINE__, String, Context) + // logs an error with additional identifing string. + +GENESISAPI geBoolean geErrorLog_AppendStringToLastError(const char *String);// use geErrorLog_AppendString + + #define geErrorLog_AppendString(XXX) geErrorLog_AppendStringToLastError(XXX) + // adds text to the previous logged error + +#else + // 'Release' version does not include the textual error id, or the user string + + #define geErrorLog_Add(Error, Context) geErrorLog_AddExplicit(Error, "", __FILE__, __LINE__,"", Context) + // logs an error. + + #define geErrorLog_AddString(Error,String, Context) geErrorLog_AddExplicit(Error, "", __FILE__,__LINE__, "", Context) + // logs an error with additional identifing string. + + #define geErrorLog_AppendString(XXX) + // adds text to the previous logged error + +#endif + +GENESISAPI geBoolean geErrorLog_Report(int History, geErrorLog_ErrorClassType *Error, const char **UserString); + // reports from the error log. + // history is 0 for most recent, 1.. for second most recent etc. + // returns GE_TRUE if report succeeded. GE_FALSE if it failed. + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/include/GETypes.h b/include/GETypes.h new file mode 100644 index 0000000..e8f2573 --- /dev/null +++ b/include/GETypes.h @@ -0,0 +1,140 @@ +/****************************************************************************************/ +/* GeTypes.h */ +/* */ +/* Description: Genesis Types (not primitive enough for basetype) */ +/* */ +/* The contents of this file are subject to the Genesis3D Public License */ +/* Version 1.01 (the "License"); you may not use this file except in */ +/* compliance with the License. You may obtain a copy of the License at */ +/* http://www.genesis3d.com */ +/* */ +/* Software distributed under the License is distributed on an "AS IS" */ +/* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */ +/* the License for the specific language governing rights and limitations */ +/* under the License. */ +/* */ +/* The Original Code is Genesis3D, released March 25, 1999. */ +/* Genesis3D Version 1.1 released November 15, 1999 */ +/* Copyright (C) 1999 WildTangent, Inc. All Rights Reserved */ +/* */ +/****************************************************************************************/ +#ifndef GE_TYPES_H +#define GE_TYPES_H + +#include "BaseType.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +// +// Collision defines (for geWorld_Collision) +// +#define GE_COLLIDE_MESHES (1<<0) +#define GE_COLLIDE_MODELS (1<<1) +#define GE_COLLIDE_ACTORS (1<<2) +#define GE_COLLIDE_NO_SUB_MODELS (1<<3) +#define GE_COLLIDE_ALL (GE_COLLIDE_MESHES | GE_COLLIDE_MODELS | GE_COLLIDE_ACTORS) + +// +// Actor flags (geWorld_AddActor) +// +#define GE_ACTOR_RENDER_NORMAL (1<<0) // Render in normal views +#define GE_ACTOR_RENDER_MIRRORS (1<<1) // Render in mirror views +#define GE_ACTOR_RENDER_ALWAYS (1<<2) // Render always, skipping all visibility tests +#define GE_ACTOR_COLLIDE (1<<3) // Collide when calling geWorld_Collision + +//MRB BEGIN +//geSprite +// +// Sprite flags (geSprite_AddSprite) +// +#define GE_SPRITE_RENDER_NORMAL (1<<0) // Render in normal views +#define GE_SPRITE_RENDER_MIRRORS (1<<1) // Render in mirror views +#define GE_SPRITE_RENDER_ALWAYS (1<<2) // Render always, skipping all visibility tests +#define GE_SPRITE_COLLIDE (1<<3) // Collide when calling geWorld_Collision +//MRB END + +typedef struct +{ + geBoolean UseEnvironmentMapping; //toggle for actor-level environ-map + geBoolean Supercede; //toggle for material-level + geFloat PercentEnvironment; + geFloat PercentMaterial; //Used when Supercede == GE_FALSE + geFloat PercentPuppet; +} geEnvironmentOptions; + +// +// Model flags (geWorld_ModelSetFlags) +// +#define GE_MODEL_RENDER_NORMAL (1<<0) // Render in normal views +#define GE_MODEL_RENDER_MIRRORS (1<<1) // Render in mirror views +#define GE_MODEL_RENDER_ALWAYS (1<<2) // Render always, skipping all visibility tests +#define GE_MODEL_COLLIDE (1<<3) // Collide when calling geWorld_Collision + +//MRB BEGIN +typedef struct +{ + geFloat r, g, b; +} geColor; + +typedef struct +{ + geFloat u, v; +} geUV; +//MRB END + +typedef struct +{ + geFloat r, g, b, a; +} GE_RGBA; + +typedef struct +{ + int32 Left; + int32 Right; + int32 Top; + int32 Bottom; +} GE_Rect; + +typedef struct +{ + geFloat MinX,MaxX; + geFloat MinY,MaxY; +} geFloatRect; + +//MRB BEGIN +typedef struct +{ + geFloat X; + geFloat Y; +} geCoordinate; +//MRB END + +// Lit vertex +typedef struct +{ + // FIXME: Convert 3d X,Y,Z to geVec3d + geFloat X, Y, Z; // 3d vertex + geFloat u, v; // Uv's + // FIXME: Convert r,g,b,a to GE_RGBA + geFloat r, g, b, a; // color +} GE_LVertex; + +// Transformed Lit vertex +typedef struct +{ + geFloat x, y, z; // screen points + geFloat u, v; // Uv's + geFloat r, g, b, a; // color +} GE_TLVertex; + +typedef GE_Rect geRect; + +#ifdef __cplusplus +} +#endif + + +#endif //GETYPES_H diff --git a/include/PixelFormat.h b/include/PixelFormat.h new file mode 100644 index 0000000..539f696 --- /dev/null +++ b/include/PixelFormat.h @@ -0,0 +1,152 @@ +#ifndef PIXELFORMAT_H +#define PIXELFORMAT_H + +/****************************************************************************************/ +/* PixelFormat.h */ +/* */ +/* Author: Charles Bloom */ +/* Description: The abstract Pixel primitives */ +/* */ +/* The contents of this file are subject to the Genesis3D Public License */ +/* Version 1.01 (the "License"); you may not use this file except in */ +/* compliance with the License. You may obtain a copy of the License at */ +/* http://www.genesis3d.com */ +/* */ +/* Software distributed under the License is distributed on an "AS IS" */ +/* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */ +/* the License for the specific language governing rights and limitations */ +/* under the License. */ +/* */ +/* The Original Code is Genesis3D, released March 25, 1999. */ +/* Genesis3D Version 1.1 released November 15, 1999 */ +/* Copyright (C) 1999 WildTangent, Inc. All Rights Reserved */ +/* */ +/****************************************************************************************/ + +#include "BaseType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum // all supported formats (including shifts) +{ + GE_PIXELFORMAT_NO_DATA = 0, + GE_PIXELFORMAT_8BIT, // PAL + GE_PIXELFORMAT_8BIT_GRAY, // no palette (intensity from bit value) + GE_PIXELFORMAT_16BIT_555_RGB, + GE_PIXELFORMAT_16BIT_555_BGR, + GE_PIXELFORMAT_16BIT_565_RGB, // #5 + GE_PIXELFORMAT_16BIT_565_BGR, + GE_PIXELFORMAT_16BIT_4444_ARGB, // #7 + GE_PIXELFORMAT_16BIT_1555_ARGB, + GE_PIXELFORMAT_24BIT_RGB, // #9 + GE_PIXELFORMAT_24BIT_BGR, + GE_PIXELFORMAT_24BIT_YUV, // * see note below + GE_PIXELFORMAT_32BIT_RGBX, + GE_PIXELFORMAT_32BIT_XRGB, + GE_PIXELFORMAT_32BIT_BGRX, + GE_PIXELFORMAT_32BIT_XBGR, + GE_PIXELFORMAT_32BIT_RGBA, + GE_PIXELFORMAT_32BIT_ARGB, // #17 + GE_PIXELFORMAT_32BIT_BGRA, + GE_PIXELFORMAT_32BIT_ABGR, + + GE_PIXELFORMAT_WAVELET, // #20 , Wavelet Compression + + GE_PIXELFORMAT_COUNT +} gePixelFormat; + +/****** + +there's something wacked out about these format names : + + for 16 bit & 32 bit , the _RGB or _BGR refers to their order + *in the word or dword* ; since we're on intel, this means + the bytes in the data file have the *opposite* order !! + (for example the 32 bit _ARGB is actually B,G,R,A in raw bytes) + for 24 bit , the _RGB or _BGR refers to their order in the + actual bytes, so that windows bitmaps actually have + _RGB order in a dword !! + +* YUV : the pixelformat ops here are identical to those of 24bit_RGB ; + this is just a place-keeper to notify you that you should to a YUV_to_RGB conversion + +*********/ + +#define GE_PIXELFORMAT_8BIT_PAL GE_PIXELFORMAT_8BIT + +typedef uint32 (*gePixelFormat_Composer )(int R,int G,int B,int A); +typedef void (*gePixelFormat_Decomposer )(uint32 Pixel,int *R,int *G,int *B,int *A); + +typedef void (*gePixelFormat_ColorGetter)(uint8 **ppData,int *R,int *G,int *B,int *A); +typedef void (*gePixelFormat_ColorPutter)(uint8 **ppData,int R,int G,int B,int A); + +typedef uint32 (*gePixelFormat_PixelGetter)(uint8 **ppData); +typedef void (*gePixelFormat_PixelPutter)(uint8 **ppData,uint32 Pixel); + +typedef struct gePixelFormat_Operations +{ + uint32 RMask; + uint32 GMask; + uint32 BMask; + uint32 AMask; + + int RShift; + int GShift; + int BShift; + int AShift; + + int RAdd; + int GAdd; + int BAdd; + int AAdd; + + int BytesPerPel; + geBoolean HasPalette; + char * Description; + + gePixelFormat_Composer ComposePixel; + gePixelFormat_Decomposer DecomposePixel; + + gePixelFormat_ColorGetter GetColor; + gePixelFormat_ColorPutter PutColor; + + gePixelFormat_PixelGetter GetPixel; + gePixelFormat_PixelPutter PutPixel; +} gePixelFormat_Operations; + + // the Masks double as boolean "HaveAlpha" .. etc.. + +GENESISAPI const gePixelFormat_Operations * GENESISCC gePixelFormat_GetOperations( gePixelFormat Format ); + + // quick accessors to _GetOps +GENESISAPI geBoolean GENESISCC gePixelFormat_IsValid( gePixelFormat Format); +GENESISAPI unsigned int GENESISCC gePixelFormat_BytesPerPel( gePixelFormat Format ); +GENESISAPI geBoolean GENESISCC gePixelFormat_HasPalette( gePixelFormat Format ); +GENESISAPI geBoolean GENESISCC gePixelFormat_HasAlpha( gePixelFormat Format ); +GENESISAPI geBoolean GENESISCC gePixelFormat_HasGoodAlpha( gePixelFormat Format ); // more than 1 bit of alpha +GENESISAPI const char * GENESISCC gePixelFormat_Description( gePixelFormat Format ); +GENESISAPI geBoolean GENESISCC gePixelFormat_IsRaw( gePixelFormat Format ); + // 'Raw' means pixels can be made with the Compose operations + +GENESISAPI uint32 GENESISCC gePixelFormat_ComposePixel( gePixelFormat Format,int R,int G,int B,int A); +GENESISAPI void GENESISCC gePixelFormat_DecomposePixel( gePixelFormat Format,uint32 Pixel,int *R,int *G,int *B,int *A); + + // these four functions move ppData to the next pixel + +GENESISAPI void GENESISCC gePixelFormat_GetColor(gePixelFormat Format,uint8 **ppData,int *R,int *G,int *B,int *A); +GENESISAPI void GENESISCC gePixelFormat_PutColor(gePixelFormat Format,uint8 **ppData,int R,int G,int B,int A); + +GENESISAPI uint32 GENESISCC gePixelFormat_GetPixel(gePixelFormat Format,uint8 **ppData); +GENESISAPI void GENESISCC gePixelFormat_PutPixel(gePixelFormat Format,uint8 **ppData,uint32 Pixel); + +GENESISAPI uint32 GENESISCC gePixelFormat_ConvertPixel(gePixelFormat Format,uint32 Pixel,gePixelFormat ToFormat); + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/include/Ram.h b/include/Ram.h new file mode 100644 index 0000000..e7a7ec0 --- /dev/null +++ b/include/Ram.h @@ -0,0 +1,140 @@ +/****************************************************************************************/ +/* RAM.H */ +/* */ +/* Author: */ +/* Description: Replacement for malloc, realloc and free */ +/* */ +/* The contents of this file are subject to the Genesis3D Public License */ +/* Version 1.01 (the "License"); you may not use this file except in */ +/* compliance with the License. You may obtain a copy of the License at */ +/* http://www.genesis3d.com */ +/* */ +/* Software distributed under the License is distributed on an "AS IS" */ +/* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */ +/* the License for the specific language governing rights and limitations */ +/* under the License. */ +/* */ +/* The Original Code is Genesis3D, released March 25, 1999. */ +/* Genesis3D Version 1.1 released November 15, 1999 */ +/* Copyright (C) 1999 WildTangent, Inc. All Rights Reserved */ +/* */ +/****************************************************************************************/ +#ifndef GE_RAM_H +#define GE_RAM_H + +#include "BaseType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef int (* geRam_CriticalCallbackFunction)(void); + +/* + Set the critical callback function. ram_allocate will call the critical + callback function if it's unable to allocate memory. +*/ +GENESISAPI geRam_CriticalCallbackFunction geRam_SetCriticalCallback + ( + geRam_CriticalCallbackFunction callback + ); + +/* + increments or decrements a counter . if the counter is >0 + the critical callback function (if set) is called for a failed memory allocation. + add is added to the current counter value. the new counter value is returned. +*/ +GENESISAPI int geRam_EnableCriticalCallback(int add); + + +/* + Allocate memory of the given size. In debug mode, the memory is filled + with 0xA5, and we keep track of the amount of memory allocated. Also, in debug + mode, we track where the memory was allocated and can optionally provide a + report of allocated blocks. See geRam_ReportAllocations. +*/ +#ifndef NDEBUG + +#define geRam_Allocate(size) _geRam_DebugAllocate(size, __FILE__, __LINE__) + +// Do not call _geRam_DebugAllocate directly. +GENESISAPI void* _geRam_DebugAllocate(uint32 size, const char* pFile, int line); + +#else + +GENESISAPI void *geRam_Allocate(uint32 size); + +#endif + +/* + Free an allocated memory block. +*/ +GENESISAPI void geRam_Free_(void *ptr); + + extern void *StupidUnusedPointer; // never used, except to mask the + // possible warning you get if you use the geRam_Free macro below, without + // using the xxx pointer again in the same block. This is ugly. + +#define geRam_Free(xxx) geRam_Free_(xxx) ,(xxx)=NULL, StupidUnusedPointer=(xxx) + +/* + Reallocate memory. This function supports shrinking and expanding blocks, + and will also act like ram_allocate if the pointer passed to it is NULL. + It won't, however, free the memory if you pass it a 0 size. +*/ +#ifndef NDEBUG + +#define geRam_Realloc(ptr, newsize) _geRam_DebugRealloc(ptr, newsize, __FILE__, __LINE__) + +// Do not call _geRam_DebugRealloc directly. +GENESISAPI void* _geRam_DebugRealloc(void* ptr, uint32 size, const char* pFile, int line); + +#else + +GENESISAPI void *geRam_Realloc(void *ptr,uint32 newsize); + +#endif + +#ifndef NDEBUG + +GENESISAPI void geRam_ReportAllocations(void); + +#else + +#define geRam_ReportAllocations() + +#endif + +#ifndef NDEBUG + extern int32 geRam_CurrentlyUsed; + extern int32 geRam_NumberOfAllocations; + extern int32 geRam_MaximumUsed; + extern int32 geRam_MaximumNumberOfAllocations; + +GENESISAPI void geRam_AddAllocation(int n,uint32 size); +#else + #define geRam_AddAllocation(n,s) +#endif + +// allocate the ram & clear it. (calloc) +GENESISAPI void * geRam_AllocateClear(uint32 size); + +#define GE_RAM_ALLOCATE_STRUCT(type) (type *)geRam_Allocate (sizeof (type)) +#define GE_RAM_ALLOCATE_ARRAY(type,count) (type *)geRam_Allocate (sizeof (type) * (count)) + +#ifndef NDEBUG +#define GE_RAM_REALLOC_ARRAY(ptr,type,count) (type *)geRam_Realloc( (ptr), sizeof(type) * (count) );{type *XX=(ptr);} +#else +#define GE_RAM_REALLOC_ARRAY(ptr,type,count) (type *)geRam_Realloc( (ptr), sizeof(type) * (count) ) +#endif + +#ifndef NDEBUG +geBoolean geRam_IsValidPtr(void *ptr); +#endif + +#ifdef __cplusplus + } +#endif + +#endif + diff --git a/include/Vec3d.h b/include/Vec3d.h new file mode 100644 index 0000000..32badd1 --- /dev/null +++ b/include/Vec3d.h @@ -0,0 +1,70 @@ +/****************************************************************************************/ +/* VEC3D.H */ +/* */ +/* Author: */ +/* Description: 3D Vector interface */ +/* */ +/* The contents of this file are subject to the Genesis3D Public License */ +/* Version 1.01 (the "License"); you may not use this file except in */ +/* compliance with the License. You may obtain a copy of the License at */ +/* http://www.genesis3d.com */ +/* */ +/* Software distributed under the License is distributed on an "AS IS" */ +/* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */ +/* the License for the specific language governing rights and limitations */ +/* under the License. */ +/* */ +/* The Original Code is Genesis3D, released March 25, 1999. */ +/* Genesis3D Version 1.1 released November 15, 1999 */ +/* Copyright (C) 1999 WildTangent, Inc. All Rights Reserved */ +/* */ +/****************************************************************************************/ +#ifndef GE_VEC3D_H +#define GE_VEC3D_H + +#include "BaseType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct +{ + geFloat X, Y, Z; +} geVec3d; + +#ifndef NDEBUG +GENESISAPI geFloat GENESISCC geVec3d_GetElement(geVec3d *V, int Index); +#else + #define geVec3d_GetElement(Vector,Index) (* ((&((Vector)->X)) + (Index) )) +#endif + +GENESISAPI void GENESISCC geVec3d_Set(geVec3d *V, geFloat X, geFloat Y, geFloat Z); +GENESISAPI void GENESISCC geVec3d_Get(const geVec3d *V, geFloat *X, geFloat *Y, geFloat *Z); + +GENESISAPI geFloat GENESISCC geVec3d_DotProduct(const geVec3d *V1, const geVec3d *V2); +GENESISAPI void GENESISCC geVec3d_CrossProduct(const geVec3d *V1, const geVec3d *V2, geVec3d *VResult); +GENESISAPI geBoolean GENESISCC geVec3d_Compare(const geVec3d *V1, const geVec3d *V2,geFloat tolarance); +GENESISAPI geFloat GENESISCC geVec3d_Normalize(geVec3d *V1); +GENESISAPI geBoolean GENESISCC geVec3d_IsNormalized(const geVec3d *V); +GENESISAPI void GENESISCC geVec3d_Scale(const geVec3d *VSrc, geFloat Scale, geVec3d *VDst); +GENESISAPI geFloat GENESISCC geVec3d_Length(const geVec3d *V1); +GENESISAPI geFloat GENESISCC geVec3d_LengthSquared(const geVec3d *V1); +GENESISAPI void GENESISCC geVec3d_Subtract(const geVec3d *V1, const geVec3d *V2, geVec3d *V1MinusV2); +GENESISAPI void GENESISCC geVec3d_Add(const geVec3d *V1, const geVec3d *V2, geVec3d *VSum); +GENESISAPI void GENESISCC geVec3d_Copy(const geVec3d *Vsrc, geVec3d *Vdst); +GENESISAPI void GENESISCC geVec3d_Clear(geVec3d *V); +GENESISAPI void GENESISCC geVec3d_Inverse(geVec3d *V); +GENESISAPI void GENESISCC geVec3d_MA(geVec3d *V1, geFloat Scale, const geVec3d *V2, geVec3d *V1PlusV2Scaled); +GENESISAPI void GENESISCC geVec3d_AddScaled(const geVec3d *V1, const geVec3d *V2, geFloat Scale, geVec3d *V1PlusV2Scaled); + +GENESISAPI geFloat GENESISCC geVec3d_DistanceBetween(const geVec3d *V1, const geVec3d *V2); // returns length of V1-V2 + +GENESISAPI geBoolean GENESISCC geVec3d_IsValid(const geVec3d *V); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/include/XForm3d.h b/include/XForm3d.h new file mode 100644 index 0000000..2a59fa5 --- /dev/null +++ b/include/XForm3d.h @@ -0,0 +1,225 @@ +/****************************************************************************************/ +/* XFORM3D.H */ +/* */ +/* Author: */ +/* Description: 3D transform interface */ +/* */ +/* The contents of this file are subject to the Genesis3D Public License */ +/* Version 1.01 (the "License"); you may not use this file except in */ +/* compliance with the License. You may obtain a copy of the License at */ +/* http://www.genesis3d.com */ +/* */ +/* Software distributed under the License is distributed on an "AS IS" */ +/* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */ +/* the License for the specific language governing rights and limitations */ +/* under the License. */ +/* */ +/* The Original Code is Genesis3D, released March 25, 1999. */ +/* Genesis3D Version 1.1 released November 15, 1999 */ +/* Copyright (C) 1999 WildTangent, Inc. All Rights Reserved */ +/* */ +/****************************************************************************************/ +#ifndef GE_XFORM_H +#define GE_XFORM_H + + +#include "Vec3d.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct +{ + geFloat AX,AY,AZ; // e[0][0],e[0][1],e[0][2] + geFloat BX,BY,BZ; // e[1][0],e[1][1],e[1][2] + geFloat CX,CY,CZ; // e[2][0],e[2][1],e[2][2] + geVec3d Translation; // e[0][3],e[1][3],e[2][3] + // 0,0,0,1 // e[3][0],e[3][1],e[3][2] +} geXForm3d; + +/* this is essentially a 'standard' 4x4 transform matrix, + with the bottom row always 0,0,0,1 + + | AX, AY, AZ, Translation.X | + | BX, BY, BZ, Translation.Y | + | CX, CY, CZ, Translation.Z | + | 0, 0, 0, 1 | +*/ + +// all geXForm3d_Set* functions return a right-handed transform. + +#define GEXFORM3D_MINIMUM_SCALE (0.00001f) + + +GENESISAPI void GENESISCC geXForm3d_Copy( + const geXForm3d *Src, + geXForm3d *Dst); + // copies Src to Dst. + +GENESISAPI geBoolean GENESISCC geXForm3d_IsValid(const geXForm3d *M); + // returns GE_TRUE if M is 'valid' + // 'valid' means that M is non NULL, and there are no NAN's in the matrix. + +//MRB BEGIN +GENESISAPI geBoolean GENESISCC geXForm3d_IsIdentity(const geXForm3d *M); + // returns GE_TRUE if M is an identity matrix +//MRB END + +GENESISAPI geBoolean GENESISCC geXForm3d_IsOrthonormal(const geXForm3d *M); + // returns GE_TRUE if M is orthonormal + // (if the rows and columns are all normalized (transform has no scaling or shearing) + // and is orthogonal (row1 cross row2 = row3 & col1 cross col2 = col3) + // * does not check for right-handed convention * + +GENESISAPI geBoolean GENESISCC geXForm3d_IsOrthogonal(const geXForm3d *M); + // returns GE_TRUE if M is orthogonal + // (row1 cross row2 = row3 & col1 cross col2 = col3) + // * does not check for right-handed convention * + +GENESISAPI void GENESISCC geXForm3d_Orthonormalize(geXForm3d *M); + // essentially removes scaling (or other distortions) from + // an orthogonal (or nearly orthogonal) matrix + // returns a right-handed matrix + + +GENESISAPI void GENESISCC geXForm3d_SetIdentity(geXForm3d *M); + // sets M to an identity matrix (clears it) + +GENESISAPI void GENESISCC geXForm3d_SetXRotation(geXForm3d *M,geFloat RadianAngle); + // sets up a transform that rotates RadianAngle about X axis + // all existing contents of M are replaced + +GENESISAPI void GENESISCC geXForm3d_SetYRotation(geXForm3d *M,geFloat RadianAngle); + // sets up a transform that rotates RadianAngle about Y axis + // all existing contents of M are replaced + +GENESISAPI void GENESISCC geXForm3d_SetZRotation(geXForm3d *M,geFloat RadianAngle); + // sets up a transform that rotates RadianAngle about Z axis + // all existing contents of M are replaced + +GENESISAPI void GENESISCC geXForm3d_SetTranslation(geXForm3d *M,geFloat x, geFloat y, geFloat z); + // sets up a transform that translates x,y,z + // all existing contents of M are replaced + +GENESISAPI void GENESISCC geXForm3d_SetScaling(geXForm3d *M,geFloat x, geFloat y, geFloat z); + // sets up a transform that scales by x,y,z + // all existing contents of M are replaced + +GENESISAPI void GENESISCC geXForm3d_RotateX(geXForm3d *M,geFloat RadianAngle); + // Rotates M by RadianAngle about X axis + // applies the rotation to the existing contents of M + +GENESISAPI void GENESISCC geXForm3d_RotateY(geXForm3d *M,geFloat RadianAngle); + // Rotates M by RadianAngle about Y axis + // applies the rotation to the existing contents of M + +GENESISAPI void GENESISCC geXForm3d_RotateZ(geXForm3d *M,geFloat RadianAngle); + // Rotates M by RadianAngle about Z axis + // applies the rotation to the existing contents of M + +GENESISAPI void GENESISCC geXForm3d_Translate(geXForm3d *M,geFloat x, geFloat y, geFloat z); + // Translates M by x,y,z + // applies the translation to the existing contents of M + +GENESISAPI void GENESISCC geXForm3d_Scale(geXForm3d *M,geFloat x, geFloat y, geFloat z); + // Scales M by x,y,z + // applies the scale to the existing contents of M + +GENESISAPI void GENESISCC geXForm3d_Multiply( + const geXForm3d *M1, + const geXForm3d *M2, + geXForm3d *MProduct); + // MProduct = matrix multiply of M1*M2 + // Concatenates the transformation in the M2 matrix onto the transformation in M1 + +GENESISAPI void GENESISCC geXForm3d_Transform( + const geXForm3d *M, + const geVec3d *V, + geVec3d *Result); + // Result is Matrix M * Vector V: V Tranformed by M + +GENESISAPI void GENESISCC geXForm3d_TransformArray( const geXForm3d *XForm, + const geVec3d *Source, + geVec3d *Dest, + int32 Count); + +GENESISAPI void GENESISCC geXForm3d_Rotate( + const geXForm3d *M, + const geVec3d *V, + geVec3d *Result); + // Result is Matrix M * Vector V: V Rotated by M (no translation) + + +/*** +* + "Left,Up,In" are just the basis vectors in the new coordinate space. + You can get them by multiplying the unit bases into the transforms. +* +******/ + +GENESISAPI void GENESISCC geXForm3d_GetLeft(const geXForm3d *M, geVec3d *Left); + // Gets a vector that is 'left' in the frame of reference of M (facing -Z) + +GENESISAPI void GENESISCC geXForm3d_GetUp(const geXForm3d *M, geVec3d *Up); + // Gets a vector that is 'up' in the frame of reference of M (facing -Z) + +GENESISAPI void GENESISCC geXForm3d_GetIn(const geXForm3d *M, geVec3d *In); + // Gets a vector that is 'in' in the frame of reference of M (facing -Z) + +GENESISAPI void GENESISCC geXForm3d_GetTranspose(const geXForm3d *M, geXForm3d *MTranspose); + // Gets the Transpose transform of M (M^T) + // Transpose of a matrix is the switch of the rows and columns + // The transpose is usefull because it is rapidly computed and is equal to the inverse + // transform for orthonormal transforms [inverse is (M') where M*M' = Identity ] + +GENESISAPI void GENESISCC geXForm3d_TransposeTransform( + const geXForm3d *M, + const geVec3d *V, + geVec3d *Result); + // applies the transpose transform of M to V. Result = (M^T) * V + +/***** +* + the Euler angles are subsequent rotations : + by Angles->Z around the Z axis + then by Angles->Y around the Y axis, in the newly rotate coordinates + then by Angles->X around the X axis +* +******/ + +GENESISAPI void GENESISCC geXForm3d_GetEulerAngles(const geXForm3d *M, geVec3d *Angles); + // Finds Euler angles from M and puts them into Angles + +GENESISAPI void GENESISCC geXForm3d_SetEulerAngles(geXForm3d *M, const geVec3d *Angles); + // Applies Euler angles to build M + +GENESISAPI void GENESISCC geXForm3d_SetFromLeftUpIn( + geXForm3d *M, + const geVec3d *Left, + const geVec3d *Up, + const geVec3d *In); + // Builds an geXForm3d from orthonormal Left, Up and In vectors + +GENESISAPI void GENESISCC geXForm3d_Mirror( + const geXForm3d *Source, + const geVec3d *PlaneNormal, + geFloat PlaneDist, + geXForm3d *Dest); + // Mirrors a XForm3d about a plane + + +//-------------- + +#ifndef NDEBUG + GENESISAPI void GENESISCC geXForm3d_SetMaximalAssertionMode( geBoolean Enable ); +#else + #define geXForm3d_SetMaximalAssertionMode(Enable) +#endif + +#ifdef __cplusplus +} +#endif + +#endif + -- 2.15.1