module gedo.video.ggl;



public import gedo.math.vector;



version(build)
{
	pragma(link, "ggl");
	pragma(link, "png");
	pragma(link, "SDL");
}
version(Windows)
{
	version(build)
	{
		pragma(link, "opengl32");
		pragma(link, "glu32");
	}
}
else
{
	version(build)
	{
		pragma(link, "GL");
		pragma(link, "GLU");
	}
}
//LDFLAGS=$(TMP)/libggl.a -lpng -lSDL -lGL -lGLU

extern(C):

enum GGL_BlendMode
{
	DISABLE,
	MIX,
	ADD,
	SCREEN,
}

struct GGL_Vertex
{
	Vector2D texCoord;
	Vector   position;
}

struct GGL_Face
{
	ushort[3] vertexIndices;
}

struct GGL_Matrix
{
	float[16] m;
}

typedef void* GGL_Mesh;
typedef void* GGL_SkinnedMesh;
typedef void* GGL_Texture;

void GGL_initialize(int useExtension);
void GGL_quit();
GGL_Mesh GGL_createMesh(GGL_Vertex* vertices, uint cv, GGL_Face* faces, uint cf);
GGL_SkinnedMesh GGL_createSkinnedMesh(GGL_Vertex* vertices, uint cv, GGL_Face* faces, uint cf, uint* cvInBones);
void GGL_releaseMesh(GGL_Mesh mesh);
GGL_Mesh GGL_castMesh(GGL_SkinnedMesh mesh);
void GGL_drawMesh(GGL_Mesh mesh, GGL_Texture texture, void* color);
void GGL_drawSkinnedMesh(GGL_SkinnedMesh mesh, GGL_Texture texture, void* color, GGL_Matrix* matrices);
void GGL_drawTriangleStrip(GGL_Vertex* vertices, uint cv, GGL_Texture texture);
void GGL_translate(float x, float y, float z);
void GGL_rotate(float radian, float x, float y, float z);
void GGL_scale(float x, float y, float z);
void GGL_multiplyMatrix(GGL_Matrix* matrix);
void GGL_pushMatrix();
void GGL_popMatrix();
void GGL_setViewport(int left, int top, int width, int height);
void GGL_getViewport(int* left, int* bottom, int* width, int* height);
void GGL_setPerspective(double angle, double znear, double zfar);
void GGL_enter2DMode(double w, double h);
void GGL_enterBillBoardMode();
void GGL_lookAt(float* pc, float* pt, float* vu);
void GGL_getCameraPosition(float* p);
float GGL_getDepth(float x, float y, float z);
void GGL_enableDepthBuffer(int isEnable);
void GGL_clearDepthBuffer();
void GGL_lockDepthBuffer(int isLocked);
void GGL_enableAlphaBlend(int isEnable);
void GGL_setBlendMode(GGL_BlendMode mode);
void GGL_clearScreen(float r, float g, float b);
char* GGL_getError();
GGL_Texture GGL_createTexture(char* path, int compress);
GGL_Texture GGL_createTextureRGBA(void* pixels, int width, int height);
void GGL_releaseTexture(GGL_Texture texture);
uint* GGL_textureSize(GGL_Texture texture);
void GGL_wrapTexture(GGL_Texture texture, int isRepeated);
