- initial import

git-svn-id: http://moon:8086/svn/mips@1 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
2014-07-20 15:01:37 +00:00
commit 26291bca3d
1549 changed files with 3997969 additions and 0 deletions
+102
View File
@@ -0,0 +1,102 @@
#include <stdlib.h>
#include <string.h>
#include "ri.h"
#include "types.h"
#include "stack.h"
#include "graph_state.h"
#include "object.h"
#include "matrix.h"
#include "vars.h"
#include "engine.h"
static char RI_DEFAULT_FILNAME[] = "ri.pic";
// Graphics state functions
void GS_init(graph_state_t *pObj)
{
UINT32 i;
pObj->pAttr_stack = Stack_push(NULL, &pObj->pAttr, sizeof(attr_t));
pObj->pOpt_stack = Stack_push(NULL, &pObj->pOpt, sizeof(opt_t));
pObj->pXform_stack = Stack_push(NULL, &pObj->pXform, sizeof(xform_t));
// Initialize coordinate systems
for (i=0; i < NUM_COORD_SYSTEMS; i++)
{
IdentityMatrix(&pObj->pXform->space[i]);
}
// Init options
memset(pObj->pOpt, 0, sizeof(opt_t));
pObj->pOpt->display.name = RI_DEFAULT_FILNAME;
pObj->pOpt->display.type = RI_FILE;
pObj->pOpt->display.mode = RI_RGBA;
pObj->pOpt->format.xres = 640;
pObj->pOpt->format.yres = 480;
pObj->pOpt->format.ar_f = (RtFloat)1;
pObj->pOpt->format.ar_p = (RtFloat)1;
pObj->pOpt->crop[0] = (RtFloat)0;
pObj->pOpt->crop[1] = (RtFloat)1;
pObj->pOpt->crop[2] = (RtFloat)0;
pObj->pOpt->crop[3] = (RtFloat)1;
pObj->pOpt->screen[0] = (RtFloat)-1.33;
pObj->pOpt->screen[1] = (RtFloat)+1.33;
pObj->pOpt->screen[2] = (RtFloat)-1.00;
pObj->pOpt->screen[3] = (RtFloat)+1.00;
pObj->pOpt->projection.type = RI_PERSPECTIVE;
pObj->pOpt->projection.fov = (RtFloat)90;
pObj->pAttr->cs[0] = 1.0;
pObj->pAttr->cs[1] = 1.0;
pObj->pAttr->cs[2] = 1.0;
pObj->pAttr->ubasis = (RtPointer)RiBezierBasis;
pObj->pAttr->vbasis = (RtPointer)RiBezierBasis;
pObj->pAttr->ustep = RI_BEZIERSTEP;
pObj->pAttr->vstep = RI_BEZIERSTEP;
pObj->pAttr->nsides = 1;
}
void GS_free(graph_state_t *pObj)
{
pObj->pAttr_stack = Stack_free(pObj->pAttr_stack);
pObj->pOpt_stack = Stack_free(pObj->pOpt_stack);
pObj->pXform_stack = Stack_free(pObj->pXform_stack);
}
void GS_opt_push(graph_state_t *pObj)
{
pObj->pOpt_stack = Stack_push(pObj->pOpt_stack, (void*)&pObj->pOpt, sizeof(opt_t));
}
void GS_opt_pop(graph_state_t *pObj)
{
pObj->pOpt_stack = Stack_pop(pObj->pOpt_stack, (void*)&pObj->pOpt);
}
void GS_attr_push(graph_state_t *pObj)
{
pObj->pAttr_stack = Stack_push(pObj->pAttr_stack, (void*)&pObj->pAttr, sizeof(attr_t));
}
void GS_attr_pop(graph_state_t *pObj)
{
pObj->pAttr_stack = Stack_pop(pObj->pAttr_stack, (void*)&pObj->pAttr);
}
void GS_xform_push(graph_state_t *pObj)
{
pObj->pXform_stack = Stack_push(pObj->pXform_stack, (void*)&pObj->pXform, sizeof(xform_t));
GS_xform_set(pObj, pObj->curr_xform);
}
void GS_xform_pop(graph_state_t *pObj)
{
pObj->pXform_stack = Stack_pop(pObj->pXform_stack, (void*)&pObj->pXform);
GS_xform_set(pObj, pObj->curr_xform);
}
void GS_xform_set(graph_state_t *pObj, UINT32 id)
{
pObj->curr_xform = id;
pObj->pXform_curr = &pObj->pXform->space[id];
}