Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1 | #include <stdint.h> |
| 2 | |
| 3 | |
| 4 | typedef void * RsAdapter1D; |
| 5 | typedef void * RsAdapter2D; |
| 6 | typedef void * RsAllocation; |
| 7 | typedef void * RsContext; |
| 8 | typedef void * RsDevice; |
| 9 | typedef void * RsElement; |
| 10 | typedef void * RsSampler; |
| 11 | typedef void * RsScript; |
| 12 | typedef void * RsScriptBasicTemp; |
| 13 | typedef void * RsTriangleMesh; |
| 14 | typedef void * RsType; |
| 15 | typedef void * RsProgramFragment; |
| 16 | typedef void * RsProgramFragmentStore; |
Jason Sams | bba134c | 2009-06-22 15:49:21 -0700 | [diff] [blame] | 17 | typedef void * RsLight; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 18 | |
| 19 | |
| 20 | typedef struct { |
| 21 | float m[16]; |
| 22 | } rsc_Matrix; |
| 23 | |
| 24 | |
| 25 | typedef struct { |
| 26 | float v[4]; |
| 27 | } rsc_Vector4; |
| 28 | |
| 29 | #define RS_PROGRAM_VERTEX_MODELVIEW_OFFSET 0 |
| 30 | #define RS_PROGRAM_VERTEX_PROJECTION_OFFSET 16 |
| 31 | #define RS_PROGRAM_VERTEX_TEXTURE_OFFSET 32 |
| 32 | |
| 33 | typedef struct { |
Jason Sams | 462d11b | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 34 | const void * (*loadEnvVp)(uint32_t bank, uint32_t offset); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 35 | |
Jason Sams | 462d11b | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 36 | float (*loadEnvF)(uint32_t bank, uint32_t offset); |
| 37 | int32_t (*loadEnvI32)(uint32_t bank, uint32_t offset); |
| 38 | uint32_t (*loadEnvU32)(uint32_t bank, uint32_t offset); |
| 39 | void (*loadEnvVec4)(uint32_t bank, uint32_t offset, rsc_Vector4 *); |
| 40 | void (*loadEnvMatrix)(uint32_t bank, uint32_t offset, rsc_Matrix *); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 41 | |
Jason Sams | 462d11b | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 42 | void (*storeEnvF)(uint32_t bank, uint32_t offset, float); |
| 43 | void (*storeEnvI32)(uint32_t bank, uint32_t offset, int32_t); |
| 44 | void (*storeEnvU32)(uint32_t bank, uint32_t offset, uint32_t); |
| 45 | void (*storeEnvVec4)(uint32_t bank, uint32_t offset, const rsc_Vector4 *); |
| 46 | void (*storeEnvMatrix)(uint32_t bank, uint32_t offset, const rsc_Matrix *); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 47 | |
Jason Sams | 462d11b | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 48 | void (*matrixLoadIdentity)(rsc_Matrix *); |
| 49 | void (*matrixLoadFloat)(rsc_Matrix *, const float *); |
| 50 | void (*matrixLoadMat)(rsc_Matrix *, const rsc_Matrix *); |
| 51 | void (*matrixLoadRotate)(rsc_Matrix *, float rot, float x, float y, float z); |
| 52 | void (*matrixLoadScale)(rsc_Matrix *, float x, float y, float z); |
| 53 | void (*matrixLoadTranslate)(rsc_Matrix *, float x, float y, float z); |
| 54 | void (*matrixLoadMultiply)(rsc_Matrix *, const rsc_Matrix *lhs, const rsc_Matrix *rhs); |
| 55 | void (*matrixMultiply)(rsc_Matrix *, const rsc_Matrix *rhs); |
| 56 | void (*matrixRotate)(rsc_Matrix *, float rot, float x, float y, float z); |
| 57 | void (*matrixScale)(rsc_Matrix *, float x, float y, float z); |
| 58 | void (*matrixTranslate)(rsc_Matrix *, float x, float y, float z); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 59 | |
Jason Sams | 462d11b | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 60 | void (*color)(float r, float g, float b, float a); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 61 | |
Jason Sams | 462d11b | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 62 | void (*programFragmentBindTexture)(RsProgramFragment, uint32_t slot, RsAllocation); |
| 63 | void (*programFragmentBindSampler)(RsProgramFragment, uint32_t slot, RsAllocation); |
Jason Sams | fe08d99 | 2009-05-27 14:45:32 -0700 | [diff] [blame] | 64 | |
Jason Sams | 462d11b | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 65 | void (*materialDiffuse)(float r, float g, float b, float a); |
| 66 | void (*materialSpecular)(float r, float g, float b, float a); |
| 67 | void (*lightPosition)(float x, float y, float z, float w); |
| 68 | void (*materialShininess)(float s); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 69 | |
Jason Sams | 462d11b | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 70 | void (*uploadToTexture)(RsAllocation va, uint32_t baseMipLevel); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 71 | |
Jason Sams | 462d11b | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 72 | void (*enable)(uint32_t); |
| 73 | void (*disable)(uint32_t); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 74 | |
Jason Sams | 462d11b | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 75 | uint32_t (*rand)(uint32_t max); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 76 | |
Jason Sams | 462d11b | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 77 | void (*contextBindProgramFragment)(RsProgramFragment pf); |
| 78 | void (*contextBindProgramFragmentStore)(RsProgramFragmentStore pfs); |
Jason Sams | fe08d99 | 2009-05-27 14:45:32 -0700 | [diff] [blame] | 79 | |
| 80 | |
| 81 | // Drawing funcs |
Jason Sams | 462d11b | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 82 | void (*renderTriangleMesh)(RsTriangleMesh); |
| 83 | void (*renderTriangleMeshRange)(RsTriangleMesh, uint32_t start, uint32_t count); |
Jason Sams | fe08d99 | 2009-05-27 14:45:32 -0700 | [diff] [blame] | 84 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 85 | // Assumes (GL_FIXED) x,y,z (GL_UNSIGNED_BYTE)r,g,b,a |
Jason Sams | 462d11b | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 86 | void (*drawTriangleArray)(RsAllocation alloc, uint32_t count); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 87 | |
Jason Sams | 462d11b | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 88 | void (*drawRect)(int32_t x1, int32_t x2, int32_t y1, int32_t y2); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 89 | } rsc_FunctionTable; |
| 90 | |
Jason Sams | 462d11b | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 91 | typedef int (*rsc_RunScript)(uint32_t launchIndex, const rsc_FunctionTable *); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 92 | |
| 93 | |
| 94 | /* EnableCap */ |
| 95 | #define GL_LIGHTING 0x0B50 |
| 96 | |
| 97 | /* LightName */ |
| 98 | #define GL_LIGHT0 0x4000 |