2014-08-29 19:56:23 +00:00
|
|
|
/* KallistiGL for KallistiOS ##version##
|
|
|
|
|
|
|
|
libgl/gl-api.h
|
2014-09-29 02:40:41 +00:00
|
|
|
Copyright (C) 2013-2014 Josh Pearson
|
2014-08-29 19:56:23 +00:00
|
|
|
|
|
|
|
The functions defined in this header are for internal use by the API,
|
|
|
|
and not for use externally.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GL_API_H
|
|
|
|
#define GL_API_H
|
|
|
|
|
2015-01-04 23:07:57 +00:00
|
|
|
#include "gl.h"
|
|
|
|
|
2014-08-29 19:56:23 +00:00
|
|
|
typedef struct {
|
2015-01-04 23:07:57 +00:00
|
|
|
GLfloat pos[3];
|
|
|
|
GLfloat norm[3];
|
2014-08-29 19:56:23 +00:00
|
|
|
} glVertex; /* Simple Vertex used for Dynamic Vertex Lighting */
|
|
|
|
|
2015-01-04 23:07:57 +00:00
|
|
|
typedef struct {
|
|
|
|
GLfloat u, v;
|
|
|
|
} glTexCoord; /* Simple Texture Coordinate used for Multi-Texturing */
|
|
|
|
|
2015-09-06 16:47:57 +00:00
|
|
|
typedef struct {
|
|
|
|
GLfloat s, t, r, q;
|
|
|
|
} glTexCoord4f; /* 3D Texture Coordinate */
|
|
|
|
|
2014-09-29 02:40:41 +00:00
|
|
|
typedef struct {
|
|
|
|
GLushort width;
|
|
|
|
GLushort height;
|
2018-04-29 20:27:13 +00:00
|
|
|
GLuint color; /* This is the PVR texture format */
|
2014-09-29 02:40:41 +00:00
|
|
|
GLubyte env;
|
|
|
|
GLubyte filter;
|
|
|
|
GLubyte mip_map;
|
|
|
|
GLubyte uv_clamp;
|
|
|
|
GLuint index;
|
|
|
|
GLvoid *data;
|
|
|
|
GLvoid *link;
|
|
|
|
} GL_TEXTURE_OBJECT; /* KOS Open GL Texture Object */
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
GLuint texID;
|
|
|
|
GLsizei index;
|
|
|
|
GLvoid *data;
|
|
|
|
GLvoid *link;
|
|
|
|
} GL_FRAMEBUFFER_OBJECT; /* KOS Open GL Frame Buffer Object */
|
|
|
|
|
2015-01-04 23:07:57 +00:00
|
|
|
typedef struct {
|
|
|
|
pvr_poly_hdr_t hdr;
|
|
|
|
pvr_vertex_t *src;
|
|
|
|
GLuint count;
|
|
|
|
} GL_MULTITEX_OBJECT;
|
|
|
|
|
|
|
|
typedef GLushort uint16;
|
|
|
|
typedef GLubyte uint8;
|
2014-08-29 19:56:23 +00:00
|
|
|
|
|
|
|
/* Vertex Main Buffer Internal Functions */
|
2018-04-29 07:32:06 +00:00
|
|
|
void _glKosVertexBufSwitchOP();
|
|
|
|
void _glKosVertexBufSwitchTR();
|
|
|
|
void *_glKosVertexBufAddress(unsigned char list);
|
|
|
|
void *_glKosVertexBufPointer();
|
|
|
|
void *_glKosTRVertexBufPointer();
|
|
|
|
void _glKosVertexBufIncrement();
|
|
|
|
void _glKosTRVertexBufIncrement();
|
|
|
|
void _glKosVertexBufAdd(unsigned int count);
|
|
|
|
void _glKosTRVertexBufAdd(unsigned int count);
|
|
|
|
void _glKosVertexBufDecrement();
|
|
|
|
void _glKosVertexBufReset();
|
|
|
|
unsigned int _glKosVertexBufCount(unsigned char list);
|
2014-08-29 19:56:23 +00:00
|
|
|
unsigned char _glKosList();
|
2018-04-29 07:32:06 +00:00
|
|
|
void _glKosVertexBufCopy(void *src, void *dst, GLuint count);
|
|
|
|
void _glKosResetEnabledTex();
|
|
|
|
void *_glKosMultiUVBufAddress();
|
|
|
|
void *_glKosMultiUVBufPointer();
|
|
|
|
void _glKosMultiUVBufIncrement();
|
|
|
|
void _glKosMultiUVBufAdd(GLuint count);
|
|
|
|
void _glKosMultiUVBufReset();
|
2014-08-29 19:56:23 +00:00
|
|
|
|
|
|
|
/* Vertex Clip Buffer Internal Functions */
|
2018-04-29 07:32:06 +00:00
|
|
|
void *_glKosClipBufAddress();
|
|
|
|
void *_glKosClipBufPointer();
|
|
|
|
void _glKosClipBufIncrement();
|
|
|
|
void _glKosClipBufReset();
|
2014-08-29 19:56:23 +00:00
|
|
|
|
|
|
|
/* Vertex Array Buffer Internal Functions */
|
2018-04-29 07:32:06 +00:00
|
|
|
void _glKosArrayBufIncrement();
|
|
|
|
void _glKosArrayBufReset();
|
|
|
|
glVertex *_glKosArrayBufAddr();
|
|
|
|
glVertex *_glKosArrayBufPtr();
|
2014-08-29 19:56:23 +00:00
|
|
|
|
|
|
|
/* Initialize the OpenGL PVR Pipeline */
|
|
|
|
int _glKosInitPVR();
|
2015-01-04 23:07:57 +00:00
|
|
|
unsigned char _glKosInitTextures();
|
2014-08-29 19:56:23 +00:00
|
|
|
|
|
|
|
/* Compile the current Polygon Header for the PVR */
|
|
|
|
void _glKosCompileHdr();
|
|
|
|
void _glKosCompileHdrTx();
|
2015-01-04 23:07:57 +00:00
|
|
|
void _glKosCompileHdrMTx();
|
2014-09-29 02:40:41 +00:00
|
|
|
void _glKosCompileHdrT(GL_TEXTURE_OBJECT *tex);
|
2015-01-04 23:07:57 +00:00
|
|
|
void _glKosCompileHdrMT(pvr_poly_hdr_t *dst, GL_TEXTURE_OBJECT *tex);
|
2014-08-29 19:56:23 +00:00
|
|
|
|
|
|
|
/* Clipping Internal Functions */
|
|
|
|
void _glKosTransformClipBuf(pvr_vertex_t *v, GLuint verts);
|
|
|
|
unsigned int _glKosClipTriangleStrip(pvr_vertex_t *vin, pvr_vertex_t *vout, unsigned int vertices);
|
|
|
|
unsigned int _glKosClipTriangles(pvr_vertex_t *vin, pvr_vertex_t *vout, unsigned int vertices);
|
|
|
|
unsigned int _glKosClipQuads(pvr_vertex_t *vin, pvr_vertex_t *vout, unsigned int vertices);
|
|
|
|
|
|
|
|
unsigned int _glKosClipTrianglesTransformed(pvr_vertex_t *src, float *w, pvr_vertex_t *dst, GLuint count);
|
|
|
|
unsigned int _glKosClipQuadsTransformed(pvr_vertex_t *vin, float *w, pvr_vertex_t *vout, unsigned int vertices);
|
|
|
|
unsigned int _glKosClipTriangleStripTransformed(pvr_vertex_t *src, float *w, pvr_vertex_t *dst, GLuint count);
|
|
|
|
|
2015-01-04 23:07:57 +00:00
|
|
|
unsigned int _glKosClipTrianglesTransformedMT(pvr_vertex_t *src, float *w, pvr_vertex_t *dst,
|
|
|
|
GLfloat *uvsrc, glTexCoord *uvdst, GLuint uv_src_stride, GLuint count);
|
|
|
|
unsigned int _glKosClipTriangleStripTransformedMT(pvr_vertex_t *src, float *w, pvr_vertex_t *dst,
|
|
|
|
GLfloat *uvsrc, glTexCoord *uvdst, GLuint uv_src_stride, GLuint count);
|
|
|
|
unsigned int _glKosClipQuadsTransformedMT(pvr_vertex_t *src, float *w, pvr_vertex_t *dst,
|
|
|
|
GLfloat *uvsrc, glTexCoord *uvdst, GLuint uv_src_stride, GLuint count);
|
|
|
|
|
|
|
|
|
2014-08-29 19:56:23 +00:00
|
|
|
/* Lighting Internal Functions */
|
|
|
|
void _glKosInitLighting();
|
|
|
|
void _glKosEnableLight(const GLuint light);
|
|
|
|
void _glKosDisableLight(const GLuint light);
|
|
|
|
void _glKosSetEyePosition(GLfloat *position);
|
|
|
|
void _glKosVertexComputeLighting(pvr_vertex_t *v, int verts);
|
|
|
|
void _glKosVertexLight(glVertex *P, pvr_vertex_t *v);
|
|
|
|
unsigned int _glKosVertexLightColor(glVertex *P);
|
|
|
|
void _glKosVertexLights(glVertex *P, pvr_vertex_t *v, GLuint count);
|
|
|
|
|
|
|
|
/* Vertex Position Submission Internal Functions */
|
|
|
|
void _glKosVertex3ft(GLfloat x, GLfloat y, GLfloat z);
|
2014-12-20 03:07:11 +00:00
|
|
|
void _glKosVertex3ftv(const GLfloat *xyz);
|
2014-08-29 19:56:23 +00:00
|
|
|
void _glKosVertex3fc(GLfloat x, GLfloat y, GLfloat z);
|
2014-12-20 03:07:11 +00:00
|
|
|
void _glKosVertex3fcv(const GLfloat *xyz);
|
2014-08-29 19:56:23 +00:00
|
|
|
void _glKosVertex3fp(GLfloat x, GLfloat y, GLfloat z);
|
2014-12-20 03:07:11 +00:00
|
|
|
void _glKosVertex3fpv(const GLfloat *xyz);
|
2014-08-29 19:56:23 +00:00
|
|
|
void _glKosVertex3fl(GLfloat x, GLfloat y, GLfloat z);
|
2014-12-20 03:07:11 +00:00
|
|
|
void _glKosVertex3flv(const GLfloat *xyz);
|
2014-08-29 19:56:23 +00:00
|
|
|
void _glKosVertex3flc(GLfloat x, GLfloat y, GLfloat z);
|
2014-12-20 03:07:11 +00:00
|
|
|
void _glKosVertex3flcv(const GLfloat *xyz);
|
2014-08-29 19:56:23 +00:00
|
|
|
void _glKosVertex3fs(GLfloat x, GLfloat y, GLfloat z);
|
2014-12-20 03:07:11 +00:00
|
|
|
void _glKosVertex3fsv(const GLfloat *xyz);
|
2014-08-29 19:56:23 +00:00
|
|
|
|
|
|
|
/* Matrix Internal Functions */
|
|
|
|
void _glKosInitMatrix();
|
|
|
|
void _glKosMatrixLoadModelView();
|
|
|
|
void _glKosMatrixLoadModelRot();
|
|
|
|
void _glKosMatrixApplyScreenSpace();
|
|
|
|
void _glKosMatrixApplyRender();
|
|
|
|
void _glKosMatrixLoadRender();
|
2015-09-06 16:47:57 +00:00
|
|
|
void _glKosMatrixLoadTexture();
|
2014-08-29 19:56:23 +00:00
|
|
|
|
|
|
|
/* API Enabled Capabilities Internal Functions */
|
2014-09-29 02:40:41 +00:00
|
|
|
GLubyte _glKosEnabledBlend();
|
|
|
|
GLubyte _glKosEnabledTexture2D();
|
2014-08-29 19:56:23 +00:00
|
|
|
GLubyte _glKosEnabledNearZClip();
|
|
|
|
GLubyte _glKosEnabledLighting();
|
2014-09-29 02:40:41 +00:00
|
|
|
GLubyte _glKosEnabledFog();
|
|
|
|
GLubyte _glKosEnabledCulling();
|
|
|
|
GLubyte _glKosEnabledScissorTest();
|
|
|
|
GLubyte _glKosEnabledDepthTest();
|
2014-08-29 19:56:23 +00:00
|
|
|
|
|
|
|
/* RGB Pixel Colorspace Internal Functions */
|
|
|
|
uint16 __glKosAverageQuadPixelRGB565(uint16 p1, uint16 p2, uint16 p3, uint16 p4);
|
|
|
|
uint16 __glKosAverageQuadPixelARGB1555(uint16 p1, uint16 p2, uint16 p3, uint16 p4);
|
|
|
|
uint16 __glKosAverageQuadPixelARGB4444(uint16 p1, uint16 p2, uint16 p3, uint16 p4);
|
|
|
|
uint16 __glKosAverageBiPixelRGB565(uint16 p1, uint16 p2);
|
|
|
|
uint16 __glKosAverageBiPixelARGB1555(uint16 p1, uint16 p2);
|
|
|
|
uint16 __glKosAverageBiPixelARGB4444(uint16 p1, uint16 p2);
|
|
|
|
|
2014-09-29 02:40:41 +00:00
|
|
|
/* Render-To-Texture Functions */
|
|
|
|
void _glKosInitFrameBuffers();
|
|
|
|
|
|
|
|
/* Error Codes */
|
|
|
|
void _glKosThrowError(GLenum error, char *functionName);
|
|
|
|
void _glKosPrintError();
|
2017-07-22 20:00:33 +00:00
|
|
|
GLubyte _glKosHasError();
|
2014-09-29 02:40:41 +00:00
|
|
|
|
|
|
|
GLuint _glKosTextureWidth(GLuint index);
|
|
|
|
GLuint _glKosTextureHeight(GLuint index);
|
|
|
|
GLvoid *_glKosTextureData(GLuint index);
|
|
|
|
|
|
|
|
/* Frame Buffer Object Internal Functions */
|
|
|
|
GLsizei _glKosGetFBO();
|
|
|
|
GLuint _glKosGetFBOWidth(GLsizei fbi);
|
|
|
|
GLuint _glKosGetFBOHeight(GLsizei fbi);
|
|
|
|
GLvoid *_glKosGetFBOData(GLsizei fbi);
|
|
|
|
|
|
|
|
/* Internal State Cap Accessors */
|
|
|
|
GLubyte _glKosEnabledDepthTest();
|
|
|
|
GLubyte _glKosEnabledScissorTest();
|
|
|
|
GLubyte _glKosEnabledCulling();
|
|
|
|
GLubyte _glKosEnabledFog();
|
|
|
|
GLubyte _glKosEnabledLighting();
|
|
|
|
GLubyte _glKosEnabledNearZClip();
|
|
|
|
GLubyte _glKosEnabledTexture2D();
|
|
|
|
GLubyte _glKosEnabledBlend();
|
|
|
|
GLuint _glKosBlendSrcFunc();
|
|
|
|
GLuint _glKosBlendDstFunc();
|
|
|
|
GLubyte _glKosCullFaceMode();
|
|
|
|
GLubyte _glKosCullFaceFront();
|
|
|
|
GLuint _glKosDepthFunc();
|
|
|
|
GLubyte _glKosDepthMask();
|
|
|
|
GLubyte _glKosIsLightEnabled(GLubyte light);
|
|
|
|
GLubyte _glKosGetMaxLights();
|
2014-12-20 03:07:11 +00:00
|
|
|
GLuint _glKosBoundTexID();
|
|
|
|
GLuint _glKosVertexColor();
|
2015-01-04 23:07:57 +00:00
|
|
|
GLubyte _glKosMaxTextureUnits();
|
2015-09-06 16:47:57 +00:00
|
|
|
GLubyte _glKosEnabledTextureMatrix();
|
2015-01-04 23:07:57 +00:00
|
|
|
|
2017-06-01 08:32:28 +00:00
|
|
|
GL_TEXTURE_OBJECT *_glKosBoundMultiTexObject();
|
|
|
|
GLuint _glKosActiveTextureBoundTexID();
|
2015-01-04 23:07:57 +00:00
|
|
|
|
2018-04-29 07:32:06 +00:00
|
|
|
void _glKosPushMultiTexObject(GL_TEXTURE_OBJECT *tex,
|
2015-01-04 23:07:57 +00:00
|
|
|
pvr_vertex_t *src,
|
|
|
|
GLuint count);
|
|
|
|
|
|
|
|
static inline void _glKosVertexCopyPVR(const pvr_vertex_t *src, pvr_vertex_t *dst) {
|
|
|
|
*dst = *src;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void _glKosTexCoordCopy(const glTexCoord *src, glTexCoord *dst) {
|
|
|
|
*dst = *src;
|
|
|
|
}
|
2014-09-29 02:40:41 +00:00
|
|
|
|
2014-08-29 19:56:23 +00:00
|
|
|
#endif
|