-
Notifications
You must be signed in to change notification settings - Fork 0
RenderModel
unsigned char *RenderModel(vertex *model,
size_t vertexCount,
crTransform transform,
CR_RenderMode renderMode,
CRFRAGMENTPROC fragmentProc)
A pointer to the verticies of the model that is to be rendered. To know how to define a vertex please visit their documentation page.
The number of verticies in the passed pointer. If it is less than the actual number of vertices, triangles will be missing. If this number is greater than the actual number of verticies, your program will probably crash.
The current transformation of the model. This includes position, rotation and scalation, all in world space.
The mode to be used when rendering. Used to support both RENDER_MODE_MESH and RENDER_MODE_TRIANGLE_STRIP but RENDER_MODE_TRIANGLE_STRIP was broken with the introduction of calculated normals. (Working on getting it going again)
Equavalent of the fragment shader in OpenGL and gets called for every pixel of the triangle that's on the screen.
#include <cr.h>
size_t fragment(int x, int y, float u, float v, float w)
{
return 0xffff0000; // Returns red for every pixel
}
int main(void)
{
while(windowOpen)
{
/* Transform model, calculate stuff, idk */
RenderModel(model, vertexCount, transform, RENDER_MODE_MESH, fragment);
/* Display image, clear depth buffer, post processing, etc. */
}
return 0;
}