- float pos[4];
- float norm[3];
- float color[3];
- int mvtop = st.mtop[G3D_MODELVIEW];
- int ptop = st.mtop[G3D_PROJECTION];
- g3d_matrix norm_mat;
-
- VEC4(pos, vert->x, vert->y, vert->z, 1.0f);
- VEC3(norm, vert->nx, vert->ny, vert->nz);
-
- switch(space) {
- case G3D_LOCAL_SPACE:
- memcpy(norm_mat, st.mat[G3D_MODELVIEW][mvtop], 16 * sizeof(float));
- norm_mat[12] = norm_mat[13] = norm_mat[14] = 0.0f;
-
- xform4_vec3(pos, st.mat[G3D_MODELVIEW][mvtop]);
- xform3_vec3(norm, norm_mat);
-
- case G3D_VIEW_SPACE:
- if(st.opt & G3D_LIGHTING) {
- /* TODO lighting */
- color[0] = vert->r;
- color[1] = vert->g;
- color[2] = vert->b;
- }
- xform4_vec3(pos, st.mat[G3D_PROJECTION][ptop]);
-
- case G3D_CLIP_SPACE:
- /* TODO clipping */
- if(pos[3] != 0.0f) {
- pos[0] /= pos[3];
- pos[1] /= pos[3];
- pos[2] /= pos[3];
- }
-
- case G3D_SCREEN_SPACE:
- pos[0] = (pos[0] * 0.5 + 0.5) * (float)st.width;
- pos[1] = (0.5 - pos[0] * 0.5) * (float)st.height;
-
- case G3D_PIXEL_SPACE:
- break;
- }
-
- /* convert pos to 24.8 fixed point */
- res->x = (int32_t)(pos[0] * 256.0f);
- res->y = (int32_t)(pos[1] * 256.0f);
-
- /* convert tex coords to 16.16 fixed point */
- res->u = (int32_t)(vert->u * 65536.0f);
- res->v = (int32_t)(vert->v * 65536.0f);
-
- /* pass color through as is */
- res->r = color[0];
- res->g = color[1];
- res->b = color[2];