Skip to content

RenderModel

Kay Steinhoff edited this page Oct 7, 2024 · 5 revisions

unsigned char *RenderModel(vertex *model,
               size_t vertexCount,
               crTransform transform,
               CR_RenderMode renderMode,
               CRFRAGMENTPROC fragmentProc)

Parameters

model

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.

vertexCount

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.

transform

The current transformation of the model. This includes position, rotation and scalation, all in world space.

renderMode

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)

fragmentProc

Equavalent of the fragment shader in OpenGL and gets called for every pixel of the triangle that's on the screen.

Example

#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;
}

Clone this wiki locally