|
|
534343 |
#ifndef HELI_PRIVATE_H
|
|
|
534343 |
#define HELI_PRIVATE_H
|
|
|
3f9996 |
|
|
|
3f9996 |
#include <assert.h></assert.h>
|
|
|
3f9996 |
#include <string.h></string.h>
|
|
|
3f9996 |
#include <stdlib.h></stdlib.h>
|
|
|
8535a3 |
#include <stdio.h></stdio.h>
|
|
|
3f9996 |
#include <ctype.h></ctype.h>
|
|
|
3f9996 |
#include <math.h></math.h>
|
|
|
3f9996 |
|
|
|
ba9f06 |
#define GL_GLEXT_PROTOTYPES
|
|
|
f63775 |
#include <gl gl.h=""></gl>
|
|
|
87fe10 |
#include <gl glext.h=""></gl>
|
|
|
8535a3 |
|
|
|
3f9996 |
#include "common.h"
|
|
|
1d641c |
#include "animation.h"
|
|
|
1d641c |
#include "framebuffer.h"
|
|
|
3f9996 |
#include "sprite.h"
|
|
|
3954ba |
#include "font.h"
|
|
|
3f9996 |
|
|
|
3f9996 |
|
|
|
8535a3 |
// globals
|
|
|
3f9996 |
|
|
|
1c7488 |
#define HELI_PRECISION 1e-6
|
|
|
1c7488 |
#define HELI_PRECISION_SQR 1e-12
|
|
|
dba3fc |
#define HELI_MIN_FPS 1
|
|
|
dba3fc |
#define HELI_MAX_FPS 100
|
|
|
dba3fc |
#define HELI_DEFAULT_FPS 24
|
|
|
1c7488 |
|
|
|
f63775 |
|
|
|
f63775 |
// blobs
|
|
|
f63775 |
|
|
|
87fe10 |
extern char heliBlobDefaultFont[] asm("heliBlobDefaultFont");
|
|
|
87fe10 |
extern int heliBlobDefaultFontSize asm("heliBlobDefaultFontSize");
|
|
|
2fcd94 |
extern char heliBlobUnicodeFont[] asm("heliBlobUnicodeFont");
|
|
|
2fcd94 |
extern int heliBlobUnicodeFontSize asm("heliBlobUnicodeFontSize");
|
|
|
3f9996 |
|
|
|
3f9996 |
|
|
|
3f9996 |
// string
|
|
|
3f9996 |
|
|
|
8535a3 |
char* heliStringCopy(const char *x);
|
|
|
bcaca0 |
char* heliStringCopyLower(const char *x);
|
|
|
dba3fc |
char* heliStringConcat(const char *a, const char *b);
|
|
|
8535a3 |
char* heliStringConcat3(const char *a, const char *b, const char *c);
|
|
|
bcaca0 |
int heliStringCompareCi(const char *a, const char *b);
|
|
|
8535a3 |
int heliStringEndsWithLowcase(const char *s, const char *tail);
|
|
|
bcaca0 |
void heliStringLower(char *x);
|
|
|
bcaca0 |
|
|
|
d4e89f |
|
|
|
d4e89f |
|
|
|
d4e89f |
// common
|
|
|
d4e89f |
|
|
|
d4e89f |
void heliColorToDouble(unsigned int code, double *rgba);
|
|
|
3f9996 |
|
|
|
09c823 |
|
|
|
3f9996 |
// pointer array
|
|
|
3f9996 |
|
|
|
8535a3 |
typedef void (*HeliFreeCallback)(void*);
|
|
|
8eb855 |
typedef void* (*HeliCloneCallback)(const void*);
|
|
|
8eb855 |
typedef int (*HeliCompareCallback)(const void*, const void*);
|
|
|
8535a3 |
|
|
|
8535a3 |
typedef struct _HeliPair {
|
|
|
8535a3 |
void *key;
|
|
|
8535a3 |
void *value;
|
|
|
8535a3 |
HeliFreeCallback freeKey;
|
|
|
8535a3 |
HeliFreeCallback freeValue;
|
|
|
8535a3 |
} HeliPair;
|
|
|
8535a3 |
|
|
|
3f9996 |
typedef struct _HeliArray {
|
|
|
8535a3 |
HeliPair *items;
|
|
|
3f9996 |
int count;
|
|
|
3f9996 |
int allocated;
|
|
|
3f9996 |
} HeliArray;
|
|
|
3f9996 |
|
|
|
8535a3 |
void heliPairInit(HeliPair *p);
|
|
|
8535a3 |
void heliPairDestroy(HeliPair *p);
|
|
|
8535a3 |
|
|
|
07b70f |
void heliArrayInit(HeliArray *a);
|
|
|
8535a3 |
void heliArrayClear(HeliArray *a);
|
|
|
07b70f |
void heliArrayDestroy(HeliArray *a);
|
|
|
8535a3 |
HeliPair* heliArrayGet(HeliArray *a, int i);
|
|
|
8535a3 |
void* heliArrayGetKey(HeliArray *a, int i);
|
|
|
8535a3 |
void* heliArrayGetValue(HeliArray *a, int i);
|
|
|
8535a3 |
HeliPair* heliArrayInsert(HeliArray *a, int i, void *v, HeliFreeCallback fv);
|
|
|
8eb855 |
HeliPair* heliArrayInsertPair(HeliArray *a, int i, void *k, HeliFreeCallback fk, void *v, HeliFreeCallback fv);
|
|
|
8535a3 |
void heliArrayRemove(HeliArray *a, int i);
|
|
|
8535a3 |
|
|
|
8eb855 |
HeliPair* heliMapFind(HeliArray *a, const void *k, HeliCompareCallback cmp, int *gtOrEqIndex);
|
|
|
8eb855 |
HeliPair* heliMapGet(HeliArray *a, const void *k, HeliCompareCallback cmp);
|
|
|
8eb855 |
HeliPair* heliMapAdd(
|
|
|
8eb855 |
HeliArray *a, const void *k, HeliCompareCallback cmp,
|
|
|
8eb855 |
HeliCloneCallback ck, HeliFreeCallback fk,
|
|
|
8eb855 |
void *v, HeliFreeCallback fv );
|
|
|
8eb855 |
int heliMapRemove(HeliArray *a, const void *k, HeliCompareCallback cmp);
|
|
|
8eb855 |
|
|
|
909bc2 |
HeliPair* heliUIntFind(HeliArray *a, size_t k, int *gtOrEqIndex);
|
|
|
909bc2 |
HeliPair* heliUIntGet(HeliArray *a, size_t k);
|
|
|
909bc2 |
HeliPair* heliUIntAdd(HeliArray *a, size_t k, void *v, HeliFreeCallback fv);
|
|
|
909bc2 |
int heliUIntRemove(HeliArray *a, size_t k);
|
|
|
909bc2 |
|
|
|
8535a3 |
HeliPair* heliStringmapFind(HeliArray *a, const char *k, int *gtOrEqIndex);
|
|
|
8535a3 |
HeliPair* heliStringmapGet(HeliArray *a, const char *k);
|
|
|
8535a3 |
HeliPair* heliStringmapAdd(HeliArray *a, const char *k, void *v, HeliFreeCallback fv);
|
|
|
8535a3 |
int heliStringmapRemove(HeliArray *a, const char *k);
|
|
|
3f9996 |
|
|
|
8535a3 |
|
|
|
8bc1f1 |
// geometry
|
|
|
8bc1f1 |
|
|
|
8bc1f1 |
void heliMatrix4Identity(double *r);
|
|
|
8bc1f1 |
void heliMatrix4Translation(double *r, double x, double y, double z);
|
|
|
8bc1f1 |
void heliMatrix4Scale(double *r, double x, double y, double z);
|
|
|
8bc1f1 |
void heliMatrix4RotationZ(double *r, double a);
|
|
|
8bc1f1 |
void heliMatrix4MultVec(double *r, const double *m, const double *v);
|
|
|
8bc1f1 |
void heliMatrix4Mult(double *r, const double *a, const double *b);
|
|
|
8bc1f1 |
int heliMatrix4Invert(double *r, const double *m);
|
|
|
8bc1f1 |
|
|
|
deef1d |
|
|
|
deef1d |
// gl
|
|
|
deef1d |
|
|
|
deef1d |
typedef struct _HeliGLClipPlaneState {
|
|
|
deef1d |
int enabled;
|
|
|
deef1d |
double equation[4];
|
|
|
deef1d |
} HeliGLClipPlaneState;
|
|
|
deef1d |
|
|
|
deef1d |
typedef struct _HeliGLCommonState {
|
|
|
deef1d |
unsigned int flags;
|
|
|
deef1d |
double modelviewMatrix[16];
|
|
|
1d641c |
double projectionMatrix[16];
|
|
|
d6f40c |
double clearColor[4];
|
|
|
1d641c |
int viewport[4];
|
|
|
1d641c |
unsigned int framebuffer_read_id;
|
|
|
1d641c |
unsigned int framebuffer_draw_id;
|
|
|
deef1d |
HeliGLClipPlaneState clipPlanes[4];
|
|
|
deef1d |
} HeliGLCommonState;
|
|
|
deef1d |
|
|
|
1d641c |
typedef void (APIENTRY *HeliGLBlendFuncSeparatePtr)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
|
|
|
1d641c |
typedef void (APIENTRY *HeliGLStencilOpSeparatePtr)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
|
|
|
1d641c |
typedef void (APIENTRY *HeliGLTexImage2DMultisamplePtr)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
|
|
|
1d641c |
typedef void (APIENTRY *HeliGLGenFramebuffersPtr)(GLsizei n, GLuint *framebuffers);
|
|
|
1d641c |
typedef void (APIENTRY *HeliGLDeleteFramebuffersPtr)(GLsizei n, const GLuint *framebuffers);
|
|
|
1d641c |
typedef void (APIENTRY *HeliGLBindFramebufferPtr)(GLenum target, GLuint framebuffer);
|
|
|
1d641c |
typedef void (APIENTRY *HeliGLBlitFramebufferPtr)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
|
|
|
1d641c |
typedef void (APIENTRY *HeliGLFramebufferRenderbufferPtr)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
|
|
|
1d641c |
typedef void (APIENTRY *HeliGLFramebufferTexture2DPtr)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
|
|
|
909bc2 |
typedef GLenum (APIENTRY *HeliGLCheckFramebufferStatusPtr)(GLenum target);
|
|
|
1d641c |
typedef void (APIENTRY *HeliGLGenRenderbuffersPtr)(GLsizei n, GLuint *renderbuffers);
|
|
|
1d641c |
typedef void (APIENTRY *HeliGLDeleteRenderbuffersPtr)(GLsizei n, const GLuint *renderbuffers);
|
|
|
1d641c |
typedef void (APIENTRY *HeliGLBindRenderbufferPtr)(GLenum target, GLuint renderbuffer);
|
|
|
1d641c |
typedef void (APIENTRY *HeliGLRenderbufferStoragePtr)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
|
|
|
1d641c |
typedef void (APIENTRY *HeliGLRenderbufferStorageMultisamplePtr)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
|
|
|
1d641c |
|
|
|
1d641c |
extern HeliGLBlendFuncSeparatePtr heliGLBlendFuncSeparatePtr;
|
|
|
1d641c |
extern HeliGLStencilOpSeparatePtr heliGLStencilOpSeparatePtr;
|
|
|
1d641c |
extern HeliGLTexImage2DMultisamplePtr heliGLTexImage2DMultisamplePtr;
|
|
|
1d641c |
extern HeliGLGenFramebuffersPtr heliGLGenFramebuffersPtr;
|
|
|
1d641c |
extern HeliGLDeleteFramebuffersPtr heliGLDeleteFramebuffersPtr;
|
|
|
1d641c |
extern HeliGLBindFramebufferPtr heliGLBindFramebufferPtr;
|
|
|
1d641c |
extern HeliGLBlitFramebufferPtr heliGLBlitFramebufferPtr;
|
|
|
1d641c |
extern HeliGLFramebufferRenderbufferPtr heliGLFramebufferRenderbufferPtr;
|
|
|
1d641c |
extern HeliGLFramebufferTexture2DPtr heliGLFramebufferTexture2DPtr;
|
|
|
909bc2 |
extern HeliGLCheckFramebufferStatusPtr heliGLCheckFramebufferStatusPtr;
|
|
|
1d641c |
extern HeliGLGenRenderbuffersPtr heliGLGenRenderbuffersPtr;
|
|
|
1d641c |
extern HeliGLDeleteRenderbuffersPtr heliGLDeleteRenderbuffersPtr;
|
|
|
1d641c |
extern HeliGLBindRenderbufferPtr heliGLBindRenderbufferPtr;
|
|
|
1d641c |
extern HeliGLRenderbufferStoragePtr heliGLRenderbufferStoragePtr;
|
|
|
1d641c |
extern HeliGLRenderbufferStorageMultisamplePtr heliGLRenderbufferStorageMultisamplePtr;
|
|
|
1d641c |
|
|
|
1d641c |
extern unsigned int heliGLWindowFramebufferReadId;
|
|
|
1d641c |
extern unsigned int heliGLWindowFramebufferDrawId;
|
|
|
1d641c |
|
|
|
8bc1f1 |
double heliGLGetAAResolution();
|
|
|
8bc1f1 |
int heliGLIsIntegerClipping();
|
|
|
8bc1f1 |
int heliGLBackTransform(double *x, double *y);
|
|
|
deef1d |
void heliGLGetCommonState(HeliGLCommonState *state, unsigned int flags);
|
|
|
deef1d |
void heliGLSetCommonState(const HeliGLCommonState *state);
|
|
|
8bc1f1 |
|
|
|
8bc1f1 |
|
|
|
8eb855 |
// all objects
|
|
|
8eb855 |
|
|
|
8eb855 |
extern int heliInitialized;
|
|
|
8eb855 |
extern HeliArray heliObjectsSet;
|
|
|
8eb855 |
void heliObjectRegister(void *o, HeliFreeCallback fo);
|
|
|
8eb855 |
void heliObjectUnregister(void *o);
|
|
|
8eb855 |
|
|
|
8eb855 |
|
|
|
deef1d |
// drawing
|
|
|
deef1d |
|
|
|
deef1d |
typedef struct _HeliTextureState {
|
|
|
deef1d |
double color[4];
|
|
|
deef1d |
Animation animation;
|
|
|
deef1d |
int fixed;
|
|
|
deef1d |
double x, y, width, height;
|
|
|
deef1d |
} HeliTextureState;
|
|
|
deef1d |
|
|
|
deef1d |
typedef struct _HeliDrawingState {
|
|
|
deef1d |
unsigned int flags;
|
|
|
deef1d |
double fillColor[4];
|
|
|
deef1d |
double strokeColor[4];
|
|
|
deef1d |
double strokeWidth;
|
|
|
deef1d |
HAlign horAlign;
|
|
|
deef1d |
VAlign vertAlign;
|
|
|
deef1d |
double fontSize;
|
|
|
deef1d |
Font font;
|
|
|
deef1d |
HeliTextureState fillTexture;
|
|
|
deef1d |
HeliTextureState strokeTexture;
|
|
|
deef1d |
HeliGLCommonState glState;
|
|
|
deef1d |
} HeliDrawingState;
|
|
|
deef1d |
|
|
|
909bc2 |
HeliArray heliDrawingFramebuffersToFlush;
|
|
|
909bc2 |
|
|
|
deef1d |
HeliDrawingState *heliDrawingGetState();
|
|
|
deef1d |
HeliDrawingState *heliDrawingGetStateStack();
|
|
|
deef1d |
void heliDrawingApplyTexture(double *color, HeliTextureState *state);
|
|
|
deef1d |
void heliDrawingResetTexture();
|
|
|
deef1d |
void heliFillRectSimple(double x0, double y0, double x1, double y1, double aaBorder);
|
|
|
deef1d |
void heliFillCircleSimple(double x, double y, double r, double aaBorder);
|
|
|
deef1d |
void heliDrawingClearFrame();
|
|
|
deef1d |
void heliDrawingPrepareFrame();
|
|
|
deef1d |
void heliDrawingFinish();
|
|
|
deef1d |
|
|
|
deef1d |
|
|
|
deef1d |
// font
|
|
|
deef1d |
|
|
|
deef1d |
void heliFontFinish();
|
|
|
deef1d |
|
|
|
deef1d |
|
|
|
8535a3 |
// animation
|
|
|
8535a3 |
|
|
|
dba3fc |
void heliAnimationUpdate(double dt);
|
|
|
07b70f |
void heliAnimationFinish();
|
|
|
3f9996 |
|
|
|
3f9996 |
|
|
|
3f9996 |
// collider
|
|
|
3f9996 |
|
|
|
3f9996 |
typedef struct _HeliCollider {
|
|
|
3f9996 |
Collider type;
|
|
|
3f9996 |
double x;
|
|
|
3f9996 |
double y;
|
|
|
3f9996 |
double radius;
|
|
|
3f9996 |
double width;
|
|
|
3f9996 |
double height;
|
|
|
3f9996 |
double rotation;
|
|
|
44355f |
double bounciness;
|
|
|
44355f |
double bouncinessThreshold;
|
|
|
3f9996 |
} HeliCollider;
|
|
|
3f9996 |
|
|
|
f80a0a |
typedef struct _HeliCollisionInfo {
|
|
|
f80a0a |
int actualCollision;
|
|
|
f80a0a |
double distance;
|
|
|
f80a0a |
double dx, dy;
|
|
|
f80a0a |
double vx, vy;
|
|
|
f80a0a |
double ax, ay;
|
|
|
f80a0a |
} HeliCollisionInfo;
|
|
|
f80a0a |
|
|
|
1c7488 |
int heliCheckCollision(
|
|
|
1c7488 |
HeliCollider *a, HeliCollider *b,
|
|
|
f80a0a |
HeliCollisionInfo *info,
|
|
|
f80a0a |
double distance );
|
|
|
1c7488 |
|
|
|
3f9996 |
int heliPointCollision(HeliCollider *c, double x, double y);
|
|
|
3f9996 |
|
|
|
8535a3 |
|
|
|
8535a3 |
// sprite
|
|
|
8535a3 |
|
|
|
07b70f |
typedef void (*HeliSpriteEashInt)(Sprite, int);
|
|
|
d4e89f |
typedef void (*HeliSpriteEashUInt)(Sprite, unsigned int);
|
|
|
07b70f |
typedef void (*HeliSpriteEashDouble)(Sprite, double);
|
|
|
8535a3 |
HeliArray* heliSpriteGetGroups(Sprite sprite);
|
|
|
f80a0a |
int heliSpriteCollisionCheck(Sprite a, Sprite b, HeliCollisionInfo *info);
|
|
|
f80a0a |
void heliSpriteCollisionApply(Sprite a, Sprite b, HeliCollisionInfo *info);
|
|
|
6eadb0 |
void heliSpriteDraw(Sprite sprite);
|
|
|
6eadb0 |
void heliSpriteDrawDebug(Sprite sprite);
|
|
|
44355f |
void heliSpriteSort(HeliArray *sprites);
|
|
|
07b70f |
void heliSpriteUpdate(double dt);
|
|
|
07b70f |
void heliSpriteFinish();
|
|
|
8535a3 |
|
|
|
07b70f |
|
|
|
09c823 |
// sound
|
|
|
09c823 |
|
|
|
09c823 |
void heliSoundUpdate();
|
|
|
09c823 |
void heliSoundFinish();
|
|
|
09c823 |
|
|
|
09c823 |
|
|
|
534343 |
// world
|
|
|
534343 |
|
|
|
534343 |
typedef struct _HeliDialog {
|
|
|
534343 |
int shown;
|
|
|
534343 |
const char *question;
|
|
|
534343 |
char *answer;
|
|
|
97fe4e |
char *passwordText;
|
|
|
534343 |
int maxAnswerSize;
|
|
|
534343 |
int multiline;
|
|
|
534343 |
int password;
|
|
|
534343 |
int pos;
|
|
|
534343 |
int selPos;
|
|
|
534343 |
double scrollX;
|
|
|
534343 |
double scrollY;
|
|
|
534343 |
int success;
|
|
|
534343 |
char newText[4096];
|
|
|
534343 |
} HeliDialog;
|
|
|
534343 |
|
|
|
534343 |
void heliDialogDraw(HeliDialog *dialog);
|
|
|
534343 |
|
|
|
534343 |
|
|
|
d1f083 |
// test
|
|
|
d1f083 |
|
|
|
d1f083 |
void heliDoTests();
|
|
|
d1f083 |
|
|
|
534343 |
|
|
|
534343 |
#endif
|