Path: blob/main/RSDKv4/Renderer.hpp
817 views
#ifndef RENDERER_H1#define RENDERER_H23#define DRAWFACE_COUNT (0x1000)4#define DRAWVERTEX_COUNT (DRAWFACE_COUNT * 4)5#define DRAWINDEX_COUNT (DRAWFACE_COUNT * 6)6#define TEXTURE_COUNT (0x80)7#define MESH_COUNT (0x40)8#define RENDERSTATE_COUNT (0x100)910enum RenderBlendModes {11RENDER_BLEND_NONE,12RENDER_BLEND_ALPHA,13RENDER_BLEND_ALPHA2,14RENDER_BLEND_ALPHA3,15};1617enum TextureFormats {18TEXFMT_NONE,19TEXFMT_RGBA4444,20TEXFMT_RGBA5551,21TEXFMT_RGBA8888,22TEXFMT_RETROBUFFER,23};2425enum MeshRenderTypes {26MESH_COLORS,27MESH_NORMALS,28MESH_COLORS_NORMALS,29};3031struct DrawVertex {32float vertX;33float vertY;34float vertZ;35float normalX;36float normalY;37float normalZ;38float texCoordX;39float texCoordY;40byte r;41byte g;42byte b;43byte a;44};4546struct MatrixF {47float values[4][4];48};4950struct TextureInfo {51char fileName[64];52int width;53int height;54float widthN;55float heightN;56int format;57uint id;58};5960struct MeshVertex {61float vertX;62float vertY;63float vertZ;64float normalX;65float normalY;66float normalZ;67};6869struct MeshInfo {70char fileName[64];71DrawVertex *vertices;72ushort *indices;73ushort vertexCount;74ushort indexCount;75MeshVertex *frames;76ushort frameCount;77byte textureID;78};7980struct MeshAnimator {81float animationSpeed;82float animationTimer;83ushort frameID;84ushort loopIndex;85ushort frameCount;86byte loopAnimation;87byte animationFinished;88};8990struct RenderState {91MatrixF *renderMatrix;92DrawVertex *vertPtr;93ushort *indexPtr;94ushort indexCount;95int id;96byte blendMode;97byte useTexture;98byte useColors;99byte depthTest;100byte useNormals;101byte useFilter;102};103104extern float retroVertexList[40];105extern float screenBufferVertexList[40];106107extern int vertexListSize;108extern DrawVertex drawVertexList[DRAWVERTEX_COUNT];109extern ushort drawIndexList[DRAWINDEX_COUNT];110111extern byte vertexR;112extern byte vertexG;113extern byte vertexB;114115extern TextureInfo textureList[TEXTURE_COUNT];116extern MeshInfo meshList[MESH_COUNT];117118extern int renderStateCount;119extern RenderState renderStateList[RENDERSTATE_COUNT];120extern RenderState currentRenderState;121122// Matricies123void SetIdentityMatrixF(MatrixF *matrix);124void MatrixMultiplyF(MatrixF *matrixA, MatrixF *matrixB);125void MatrixTranslateXYZF(MatrixF *Matrix, float x, float y, float z);126void MatrixScaleXYZF(MatrixF *matrix, float scaleX, float scaleY, float scaleZ);127void MatrixRotateXF(MatrixF *matrix, float rotationX);128void MatrixRotateYF(MatrixF *matrix, float rotationY);129void MatrixRotateZF(MatrixF *matrix, float rotationZ);130void MatrixRotateXYZF(MatrixF *matrix, float rotationX, float rotationY, float rotationZ);131void MatrixInvertF(MatrixF *dstMatrix, MatrixF *matrix);132133// Render States134void ResetRenderStates();135void SetRenderBlendMode(byte mode);136void SetRenderVertexColor(byte r, byte g, byte b);137void SetPerspectiveMatrix(float w, float h, float near, float far);138void SetupDrawIndexList();139void SetRenderMatrix(MatrixF *matrix);140void NewRenderState();141void RenderScene();142143// Textures144int LoadTexture(const char *filePath, int format);145void ReplaceTexture(const char *filePath, int textureID);146void ClearTextures(bool keepBuffer);147148// Meshes149MeshInfo *LoadMesh(const char *filePath, byte textureID);150void SetMeshVertexColors(MeshInfo *mesh, byte r, byte g, byte b, byte a);151void ClearMeshData();152void SetMeshAnimation(MeshInfo *mesh, MeshAnimator *animator, ushort frameID, ushort frameCount, float speed);153void AnimateMesh(MeshInfo *mesh, MeshAnimator *animator);154155// Rendering156void TransferRetroBuffer();157void RenderRetroBuffer(int alpha, float z);158void RenderImage(float x, float y, float z, float scaleX, float scaleY, float pivotX, float pivotY, float sprW, float sprH, float sprX, float sprY,159int alpha, byte texture);160void RenderImageClipped(float x, float y, float z, float scaleX, float scaleY, float pivotX, float pivotY, float sprW, float sprH, float sprX,161float sprY, int alpha, byte texture);162void RenderImageFlipH(float x, float y, float z, float scaleX, float scaleY, float pivotX, float pivotY, float sprW, float sprH, float sprX,163float sprY, int alpha, byte texture);164void RenderText(ushort *text, int fontID, float x, float y, int z, float scale, int alpha);165void RenderTextClipped(ushort *text, int fontID, float x, float y, int z, float scale, int alpha);166void RenderRect(float x, float y, float z, float w, float h, byte r, byte g, byte b, int alpha);167#if !RETRO_USE_ORIGINAL_CODE168void RenderRectClipped(float x, float y, float z, float w, float h, byte r, byte g, byte b, int alpha);169#endif170void RenderMesh(MeshInfo *mesh, byte type, byte depthTest);171172#endif // !RENDERER_H173174