Esempio n. 1
0
// Main menu
void gfx()
{
	pvr_wait_ready();
	pvr_scene_begin();

	pvr_list_begin(PVR_LIST_OP_POLY);
		if (stateM == stateMenu || stateM == statePrintDIR)
			drawBG();
	pvr_list_finish();


	pvr_list_begin(PVR_LIST_TR_POLY);

	switch(stateM)
	{
		case statePaused:
			printPVR((DISP_WIDTH / 2) - 36, (DISP_HEIGHT / 2) - 24, "Paused");
			break;

		case stateMenu:
			printPVR(0, 0, "eCastOS 0.3.7 | EXT2");
			printPVR(0, 48, "A     : Boot romdisk Binary");
			printPVR(0, 72, "B     : List Root Directory");
			if (mountState)
				printPVR(0, 96, "X     : Un Mount G1");
			if (!mountState)
			{
				printPVR(0, 96, "X     : Mount G1");
				printPVR(0, 240, "G1    : Not Mounted");
			}
			printPVR(0, 120, "Y     : Write Hard Drive File's");
			printPVR(0, 168, "UP    : Pause Rendering PowerVR");
			printPVR(0, 192, "DOWN  : Check Settings Over Serial");
			break;

		case statePrintDIR:
			printPVR(((DISP_WIDTH / 2) - 216), 0, "  Press B To Return");
			do {
				printDIR("/hd");
		  } while (stateM == statePrintDIR);
			break;

		case stateSettings:
			break;

		case stateBoot:
			printPVR(12, 24, "Initializing eCastOS...");
			sleep(1);
			stateM = stateMenu;
			break;
	}

	pvr_list_finish();

	pvr_scene_finish();
}
Esempio n. 2
0
void do_frame() {
    pvr_modifier_vol_t mod;
    int i;

    pvr_wait_ready();
    pvr_scene_begin();
    pvr_list_begin(list);

    pvr_prim(&phdr, sizeof(phdr));

    for(i = 0; i < NUM_POLYS; ++i) {
        pvr_prim(&verts[i * 4], sizeof(verts[i * 4]));
        pvr_prim(&verts[i * 4 + 1], sizeof(verts[i * 4 + 1]));
        pvr_prim(&verts[i * 4 + 2], sizeof(verts[i * 4 + 2]));
        pvr_prim(&verts[i * 4 + 3], sizeof(verts[i * 4 + 3]));
    }

    pvr_list_finish();

    pvr_list_begin(list + 1);

    pvr_prim(&mhdr, sizeof(mhdr));

    mod.flags = PVR_CMD_VERTEX_EOL;
    mod.ax = mx;
    mod.ay = my + 50.0f;
    mod.az = 150.0f;
    mod.bx = mx;
    mod.by = my;
    mod.bz = 150.0f;
    mod.cx = mx + 50.0f;
    mod.cy = my + 50.0f;
    mod.cz = 150.0f;
    mod.d1 = mod.d2 = mod.d3 = mod.d4 = mod.d5 = mod.d6 = 0;
    pvr_prim(&mod, sizeof(mod));

    pvr_prim(&mhdr2, sizeof(mhdr2));

    mod.flags = PVR_CMD_VERTEX_EOL;
    mod.ax = mx;
    mod.ay = my;
    mod.az = 150.0f;
    mod.bx = mx + 50.0f;
    mod.by = my + 50.0f;
    mod.bz = 150.0f;
    mod.cx = mx + 50.0f;
    mod.cy = my;
    mod.cz = 150.0f;
    mod.d1 = mod.d2 = mod.d3 = mod.d4 = mod.d5 = mod.d6 = 0;
    pvr_prim(&mod, sizeof(mod));

    pvr_list_finish();
    pvr_scene_finish();
}
Esempio n. 3
0
static void
do_feedback (uint32_t time_offset, void *params, int iparam, viewpoint *view,
	     lighting *lights)
{
  uint32 tx_x = 1024, tx_y = 512;
  float tmp[4], invw;
  
  flame_pos[0] = 0;
  flame_pos[1] = (float) (4500 - ((int) time_offset % 9000)) / 1100.0;
  flame_pos[2] = 4;

  view_set_eye_pos (view, 0, 0, -4.5);
  view_set_look_at (view, 0, 0, 0);

  light_set_pos (lights, 0, flame_pos[0], flame_pos[1], flame_pos[2]);

  view_fix (view, lights);
  light_fix (view, lights);

  vec_transform3_fipr (&tmp[0], &(*view->camera)[0][0], &flame_pos[0]);
  tmp[3] = 1.0f;
  vec_transform_fipr (&flame_pos_xformed[0], &(*view->projection)[0][0],
		      &tmp[0]);
  invw = 1.0 / flame_pos_xformed[3];
  flame_pos_xformed[0] *= invw;
  flame_pos_xformed[1] *= invw;
  flame_pos_xformed[2] = invw;
  
  /* Render to texture.  */
  pvr_wait_ready ();
  pvr_scene_begin_txr (warp_texture[warp_active], &tx_x, &tx_y);

#if 0
  user_clip.d1 = 0;  /* minx.  */
  user_clip.d2 = 7;  /* miny.  */
  user_clip.d3 = 1;  /* maxx.  */
  user_clip.d4 = 9;  /* maxy.  */
#endif

  pvr_list_begin (PVR_LIST_OP_POLY);
  //pvr_prim (&user_clip, sizeof (pvr_poly_hdr_t));
  draw_box ();
  pvr_list_finish ();

  pvr_list_begin (PVR_LIST_TR_POLY);
  //pvr_prim (&user_clip, sizeof (pvr_poly_hdr_t));
  draw_cooler ();
  pvr_list_finish ();

  pvr_scene_finish ();
}
Esempio n. 4
0
int main(int argc, char **argv) {
    int done, i;
    float theta, dt;
    float colors[3*10] = {
        0.0f, 0.5f, 1.0f,
        0.0f, 1.0f, 0.0f,
        1.0f, 0.0f, 0.0f,
        0.0f, 0.0f, 1.0f,
        0.5f, 0.5f, 0.0f,
        0.5f, 0.0f, 0.5f,
        0.5f, 0.5f, 0.5f,
        0.73f, 0.8f, 0.25f,
        0.25f, 0.8f, 0.73f,
        1.0f, 1.0f, 0.0f
    };

    // Init PVR
    pvr_init_defaults();

    // Setup the context
    plx_cxt_init();
    plx_cxt_texture(NULL);
    plx_cxt_culling(PLX_CULL_NONE);

    // Until the user hits start...
    dt = 2*M_PI/160.0f;
    for (done = 0, theta = 0.0f; !done; ) {
        // Check for start
        MAPLE_FOREACH_BEGIN(MAPLE_FUNC_CONTROLLER, cont_state_t, st)
        if (st->buttons & CONT_START)
            done = 1;
        MAPLE_FOREACH_END()

        // Setup the frame
        pvr_wait_ready();
        pvr_scene_begin();
        pvr_list_begin(PVR_LIST_OP_POLY);

        // Submit the context
        plx_cxt_send(PVR_LIST_OP_POLY);

        // Draw a sinus bar at our current position and several positions
        // back. Each bar will get its own Z value (descending).
        for (i=0; i<10; i++) {
            drawbar(240.0f + fsin(theta - dt*i*6) * 120.0f, 100.0f - i,
                    colors[i*3+0], colors[i*3+1], colors[i*3+2]);
        }

        pvr_scene_finish();

        // Move our counters
        theta += dt;
        while (theta >= 2*M_PI)
            theta -= 2*M_PI;
    }

    return 0;
}
Esempio n. 5
0
static void RenderVideo(video_txr_t *txr, AVFrame *frame, AVCodecContext *codec) {

	switch(codec->pix_fmt) {
		case PIX_FMT_YUVJ420P:
		case PIX_FMT_YUVJ422P:
		case PIX_FMT_YUV420P:

#ifdef USE_HW_YUV
			yuv_conv_frame(txr, frame, codec, -1);
#else
			yuvtex(txr->backbuf, txr->tw, codec->width, codec->height,
				frame->data[0], frame->linesize[0],
				frame->data[1], frame->linesize[1],
				frame->data[2], frame->linesize[2]
			);
			
//			dcache_flush_range((unsigned)txr->backbuf, txr->tw * codec->height * 2);
//			while (!pvr_dma_ready());
//			pvr_txr_load_dma(txr->backbuf, txr->addr, txr->tw * codec->height * 2, -1, NULL, 0);
			sq_cpy(txr->addr, txr->backbuf, txr->tw * codec->height * 2);
#endif
			break;
		case PIX_FMT_UYVY422:
//			dcache_flush_range((unsigned)frame->data[0], txr->tw * codec->height * 2);
//			while (!pvr_dma_ready());
//			pvr_txr_load_dma((uint8 *)(((uint32)frame->data[0] + 31) & (~31)), txr->addr, txr->tw * codec->height * 2, -1, NULL, 0);
			sq_cpy(txr->addr, frame->data[0], txr->tw * codec->height * 2);
			break;
		default:
//			dcache_flush_range((unsigned)frame->data[0], txr->tw * codec->height * 2);
//			while (!pvr_dma_ready());
//			pvr_txr_load_dma((uint8 *)(((uint32)frame->data[0] + 31) & (~31)), txr->addr, txr->tw * codec->height * 2, -1, NULL, 0);
			sq_cpy(txr->addr, frame->data[0], txr->tw * codec->height * 2);
			break;
	}
	
	pvr_wait_ready();
	pvr_scene_begin();
	
	pvr_list_begin(PVR_LIST_OP_POLY);
	
	if (txr->addr) {
		int dispw = 640;
		int disph = 640 * txr->height/txr->width;
		RenderVideoTexture(txr, (640-dispw)/2, (480-disph)/2, dispw, disph, 0xFFFFFFFF);
	}

	pvr_list_finish();
	
	if(txr->render_cb != NULL) {
		txr->render_cb((void *)txr);
	}
	
	pvr_scene_finish();
}
Esempio n. 6
0
void pm_draw() {
	char str[64];
	float pct;
	float posx = 64, posy = 96, posz = 4500;

	// Get our stats
	pvr_stats_t stats;
	pvr_get_stats(&stats);

	// Make sure we're drawing into the right list.
	pvr_list_begin(PVR_LIST_TR_POLY);

	// Make a nice stat display
	sprintf(str, "fps %.2f  buf %d  reg %d  rnd %d",
		(double)stats.frame_rate,
		(int)stats.buf_last_time,
		(int)stats.reg_last_time,
		(int)stats.rnd_last_time);
	plx_fcxt_setcolor4f(fcxt, 1,1,1,1);
	plx_fcxt_setsize(fcxt, 16.0f);
	plx_fcxt_setpos(fcxt, posx, posy, posz);
	plx_fcxt_begin(fcxt);
	plx_fcxt_draw(fcxt, str);
	plx_fcxt_end(fcxt);

	sprintf(str, "avg fps %.2f",
		(double)(60.0 * stats.frame_count / stats.vbl_count));
	plx_fcxt_setpos(fcxt, posx, posy + 16.0f, posz);
	plx_fcxt_begin(fcxt);
	plx_fcxt_draw(fcxt, str);
	plx_fcxt_end(fcxt);

	// Draw a bargraph for registration time
	plx_cxt_texture(NULL);
	plx_cxt_send(PVR_LIST_TR_POLY);

	posy += -40.0f;

	pct = ((float)stats.buf_last_time) * 60.0f / 1000.0f;
	pm_drawbar(pct, posx, posy, posz, 0xff00c0c0, 0xff007070);

	pct = ((float)stats.reg_last_time) * 60.0f / 1000.0f;
	posy += 8.0f;
	pm_drawbar(pct, posx, posy, posz, 0xff00c000, 0xff007000);

	// Draw a bargraph for rendering time
	pct = ((float)stats.rnd_last_time) * 60.0f / 1000.0f;
	posy += 8.0f;
	pm_drawbar(pct, posx, posy, posz, 0xffc0c000, 0xff707000);

	pvr_list_finish();
}
Esempio n. 7
0
void do_frame() {
    pvr_vertex_t vert;
    int x, y, z;
    int size;
    int i, col;

    vid_border_color(0, 0, 0);
    pvr_wait_ready();
    vid_border_color(255, 0, 0);
    pvr_scene_begin();
    pvr_list_begin(PVR_LIST_OP_POLY);
    pvr_prim(&hdr, sizeof(hdr));

    x = rand() % 640;
    y = rand() % 480;
    z = rand() % 100 + 1;
    col = rand () % 256;

    vert.flags = PVR_CMD_VERTEX;
    vert.x = x;
    vert.y = y;
    vert.z = z;
    vert.u = vert.v = 0.0f;
    vert.argb = col | (col << 8) | (col << 16) | 0xff000000;
    vert.oargb = 0;
    pvr_prim(&vert, sizeof(vert));

    for (i=0; i<polycnt; i++) {
        x = (x + ((rand() % 50) - 25)) % 640;
        y = (y + ((rand() % 50) - 25)) % 480;
        col = rand () % 256;
        vert.x = x;
        vert.y = y;
        vert.argb = col | (col << 8) | (col << 16) | 0xff000000;

        if (i == (polycnt-1))
            vert.flags = PVR_CMD_VERTEX_EOL;

        pvr_prim(&vert, sizeof(vert));
    }

    pvr_list_finish();
    pvr_scene_finish();
    vid_border_color(0, 255, 0);
}
Esempio n. 8
0
/* our exported drawing function: does a full redraw of everything */
void conio_draw_frame() {
	pvr_wait_ready();
	pvr_scene_begin();
	pvr_list_begin(PVR_LIST_TR_POLY);
	switch (conio_theme) {
		case CONIO_THEME_C64:
			draw_border(0.4f, 0.6f, 0.98f);
			draw_middle(0.0f, 0.0f, 1.0f);
			draw_virtscr(1.0f, 1.0f, 1.0f, 1.0f);
			draw_cursor(0.4f, 0.6f, 0.98f);
			break;
		case CONIO_THEME_MATRIX:
			draw_virtscr(1.0f, 0.0f, 1.0f, 0.0f);
			draw_cursor(0.0f, 0.7f, 0.0f);
			break;
		case CONIO_THEME_PLAIN:
		default:
			draw_virtscr(1.0f, 1.0f, 1.0f, 1.0f);
			draw_cursor(1.0f, 1.0f, 1.0f);
			break;
	}
	pvr_list_finish();
	pvr_scene_finish();
}
Esempio n. 9
0
int main(int argc, char **argv) {
    plx_texture_t * txr;
    int done;
    float y, xoffs;

    // Init PVR
    pvr_init_defaults();

    // Load a texture
    txr = plx_txr_load("/rd/dan.jpg", 0, 0);

    if(!txr)
        return 0;

    // Setup a texture context
    plx_cxt_init();
    plx_cxt_texture(txr);
    plx_cxt_culling(PLX_CULL_NONE);

    // The image will be offset by this much from each side
    xoffs = (640 - 512) / 2;

    // Until the user hits start...
    for(done = 0, y = 0.0f; !done;) {
        // Check for start
        MAPLE_FOREACH_BEGIN(MAPLE_FUNC_CONTROLLER, cont_state_t, st)

        if(st->buttons & CONT_START)
            done = 1;

        MAPLE_FOREACH_END()

        // Setup the frame
        pvr_wait_ready();
        pvr_scene_begin();
        pvr_list_begin(PVR_LIST_OP_POLY);

        // Submit the context
        plx_cxt_send(PVR_LIST_OP_POLY);

        // Two polys -- one normal up to the scan point, and one
        // stretched to the bottom.
        plx_vert_ifp(PLX_VERT, xoffs, y, 1.0f, 0xffffffff, 0.0f, y / 480.0f);
        plx_vert_ifp(PLX_VERT, xoffs, 0.0f, 1.0f, 0xffffffff, 0.0f, 0.0f);
        plx_vert_ifp(PLX_VERT, 640.0f - xoffs, y, 1.0f, 0xffffffff, 1.0f, y / 480.0f);
        plx_vert_ifp(PLX_VERT_EOS, 640.0f - xoffs, 0.0f, 1.0f, 0xffffffff, 1.0f, 0.0f);

        plx_vert_ifp(PLX_VERT, xoffs, 480.0f, 1.0f, 0xffffffff, 0.0f, y / 480.0f);
        plx_vert_ifp(PLX_VERT, xoffs, y, 1.0f, 0xffffffff, 0.0f, y / 480.0f);
        plx_vert_ifp(PLX_VERT, 640.0f - xoffs, 480.0f, 1.0f, 0xffffffff, 1.0f, y / 480.0f);
        plx_vert_ifp(PLX_VERT_EOS, 640.0f - xoffs, y, 1.0f, 0xffffffff, 1.0f, y / 480.0f);

        pvr_scene_finish();

        // Move our scanline
        if(y < 480.0f)
            y += 2.0f;
    }

    return 0;
}
Esempio n. 10
0
int main(int argc, char **argv) {
    
    /* Controller Stuff */
    maple_device_t * dev;
    cont_state_t * state;
    
    int rquad = 0;
    int rtri = 0;
    
	/* Init PVR API */
	if (pvr_init(&params) < 0)
		return -1;
		
	printControls();	

    /* Sets the background color to black */
	pvr_set_bg_color(0.0f,0.0f,0.0f);
	
	plx_cxt_init();                 // Initialize the plx context system
	plx_cxt_texture(NULL);          // No texture will be used
    plx_cxt_culling(PLX_CULL_NONE); // No culling
	
	// GET SOME 3D GOING!!
	/* Init matrices */
	plx_mat3d_init();                    /* Clear internal to an identity matrix */
	plx_mat3d_mode(PLX_MAT_PROJECTION);  /** Projection (frustum, screenview) matrix */
	plx_mat3d_identity();                /** Load an identity matrix */
	plx_mat3d_perspective(45.0f, 640.0f / 480.0f, 0.1f, 100.0f);  // (float angle, float aspect, float znear, float zfar);
	plx_mat3d_mode(PLX_MAT_MODELVIEW);   /** Modelview (rotate, scale) matrix */
	
	while(1) {
        
        // Check for the user pressing START
		dev = maple_enum_dev(0, 0);
		if(dev == NULL) {
            printf("Error: Could not find controller in first port.\n");
            break;
        }
	    state = (cont_state_t *)maple_dev_status(dev);
	    if (state->buttons & CONT_START) {
		    break;           // exit the program
        }               
		
		pvr_wait_ready();
		pvr_scene_begin();
		pvr_list_begin(PVR_LIST_OP_POLY);
     	
		// Submit the context
		plx_cxt_send(PVR_LIST_OP_POLY);  // Submit the Header for PVR_LIST_OP_POLY
		
		// DRAW THE PYRAMID
	    plx_mat3d_identity();
	    plx_mat3d_translate(-1.5f, 0.0f, -6.0f);  // Move 1.5f units to the left and 6 units into the screen
	    plx_mat3d_rotate(rtri, 0.0f, 1.0f, 0.0f); // Rotate the pyramid angle 'rtri' on the Y axis
  	    
	    /* Clear internal to an identity matrix */
	    plx_mat_identity();
	
    	/* "Applying" all matrixs: multiply a matrix onto the "internal" one */
	    plx_mat3d_apply_all();
	    
	    // Front Face of Pyramid
	    plx_vert_inpm3(PLX_VERT, 0, 1, 0, plx_pack_color(1.0f, 1.0f, 0.0f, 0.0f));       // Red: Top Of Triangle (Front)
	    plx_vert_inpm3(PLX_VERT, -1, -1, 1, plx_pack_color(1.0f, 0.0f, 1.0f, 0.0f));     // Green: Left Of Triangle (Front)
	    plx_vert_inpm3(PLX_VERT_EOS, 1, -1, 1, plx_pack_color(1.0f, 0.0f, 0.0f, 1.0f));  // Blue: Right Of Triangle (Front)
	    
	    // Right Face of Pyramid
	    plx_vert_inpm3(PLX_VERT, 0, 1, 0, plx_pack_color(1.0f, 1.0f, 0.0f, 0.0f));       // Red: Top Of Triangle (Right)
	    plx_vert_inpm3(PLX_VERT, 1, -1, 1, plx_pack_color(1.0f, 0.0f, 0.0f, 1.0f));      // Blue: Left Of Triangle (Right)
	    plx_vert_inpm3(PLX_VERT_EOS, 1, -1, -1, plx_pack_color(1.0f, 0.0f, 1.0f, 0.0f)); // Green: Right Of Triangle (Right)
	    
	    // Back Face of Pyramid
	    plx_vert_inpm3(PLX_VERT, 0, 1, 0, plx_pack_color(1.0f, 1.0f, 0.0f, 0.0f));       // Red: Top Of Triangle (Back)
	    plx_vert_inpm3(PLX_VERT, 1, -1, -1, plx_pack_color(1.0f, 0.0f, 1.0f, 0.0f));     // Green: Left Of Triangle (Back)
	    plx_vert_inpm3(PLX_VERT_EOS, -1, -1, -1, plx_pack_color(1.0f, 0.0f, 0.0f, 1.0f));// Blue: Right Of Triangle (Back)
	    
	    // Left Face of Pyramid
	    plx_vert_inpm3(PLX_VERT, 0, 1, 0, plx_pack_color(1.0f, 1.0f, 0.0f, 0.0f));       // Red: Top Of Triangle (Left)
	    plx_vert_inpm3(PLX_VERT, -1, -1, -1, plx_pack_color(1.0f, 0.0f, 0.0f, 1.0f));    // Blue: Left Of Triangle (Left)
	    plx_vert_inpm3(PLX_VERT_EOS, -1, -1, 1, plx_pack_color(1.0f, 0.0f, 1.0f, 0.0f)); // Green: Right Of Triangle (Left)
	    
        // DRAW THE BOX	
        plx_mat3d_identity();
	    plx_mat3d_translate(1.5f, 0.0f, -6.0f);    // Move 1.5f units to the right and 6 units into the screen
	    plx_mat3d_rotate(rquad, 1.0f, 0.0f, 0.0f); // Rotate the box angle 'rquad' on the X axis 
	    
	    /* Clear internal to an identity matrix */
	    plx_mat_identity();
	    
    	/* "Applying" all matrixs: multiply a matrix onto the "internal" one */
	    plx_mat3d_apply_all();
		
		// Top Face of Box (GREEN)
		plx_vert_inpm3(PLX_VERT, -1, 1, 1, plx_pack_color(1.0f, 0.0f, 1.0f, 0.0f));     // Bottom Left Of The Quad (Top)
		plx_vert_inpm3(PLX_VERT, -1, 1, -1, plx_pack_color(1.0f, 0.0f, 1.0f, 0.0f));    // Top Left Of The Quad (Top)
		plx_vert_inpm3(PLX_VERT, 1, 1, 1, plx_pack_color(1.0f, 0.0f, 1.0f, 0.0f));      // Bottom Right Of The Quad (Top)
		plx_vert_inpm3(PLX_VERT_EOS, 1, 1, -1, plx_pack_color(1.0f, 0.0f, 1.0f, 0.0f)); // Top Right Of The Quad (Top)
	    
		// Bottom Face of Box (ORANGE)
		plx_vert_inpm3(PLX_VERT, -1, -1, -1, plx_pack_color(1.0f, 1.0f, 0.5f, 0.0f));   // Bottom Left Of The Quad (Bottom)
		plx_vert_inpm3(PLX_VERT, -1, -1, 1, plx_pack_color(1.0f, 1.0f, 0.5f, 0.0f));    // Top Left Of The Quad (Bottom)
		plx_vert_inpm3(PLX_VERT, 1, -1, -1, plx_pack_color(1.0f, 1.0f, 0.5f, 0.0f));    // Bottom Right Of The Quad (Bottom)
		plx_vert_inpm3(PLX_VERT_EOS, 1, -1, 1, plx_pack_color(1.0f, 1.0f, 0.5f, 0.0f)); // Top Right Of The Quad (Bottom)	    
		
		// Front Face of Box (RED)
		plx_vert_inpm3(PLX_VERT, -1, -1, 1, plx_pack_color(1.0f, 1.0f, 0.0f, 0.0f));    // Bottom Left Of The Quad (Front)
	    plx_vert_inpm3(PLX_VERT, -1, 1, 1, plx_pack_color(1.0f, 1.0f, 0.0f, 0.0f));     // Top Left Of The Quad (Front)
	    plx_vert_inpm3(PLX_VERT, 1, -1, 1, plx_pack_color(1.0f, 1.0f, 0.0f, 0.0f));     // Bottom Right Of The Quad (Front)
	    plx_vert_inpm3(PLX_VERT_EOS, 1, 1, 1, plx_pack_color(1.0f, 1.0f, 0.0f, 0.0f));  // Top Right Of The Quad (Front)
		
		// Back Face of Box (YELLOW)
		plx_vert_inpm3(PLX_VERT, -1, 1, -1, plx_pack_color(1.0f, 1.0f, 1.0f, 0.0f));    // Bottom Left Of The Quad (Back)
	    plx_vert_inpm3(PLX_VERT, -1, -1, -1, plx_pack_color(1.0f, 1.0f, 1.0f, 0.0f));   // Top Left Of The Quad (Back)
	    plx_vert_inpm3(PLX_VERT, 1, 1, -1, plx_pack_color(1.0f, 1.0f, 1.0f, 0.0f));     // Bottom Right Of The Quad (Back)
		plx_vert_inpm3(PLX_VERT_EOS, 1, -1, -1, plx_pack_color(1.0f, 1.0f, 1.0f, 0.0f));// Top Right Of The Quad (Back)
		
		// Left Face of Box (BLUE)
		plx_vert_inpm3(PLX_VERT, -1, -1, -1, plx_pack_color(1.0f, 0.0f, 0.0f, 1.0f));   // Bottom Left Of The Quad (Left)
	    plx_vert_inpm3(PLX_VERT, -1, 1, -1, plx_pack_color(1.0f, 0.0f, 0.0f, 1.0f));    // Top Left Of The Quad (Left)
	    plx_vert_inpm3(PLX_VERT, -1, -1, 1, plx_pack_color(1.0f, 0.0f, 0.0f, 1.0f));    // Bottom Right Of The Quad (Left)
	    plx_vert_inpm3(PLX_VERT_EOS, -1, 1, 1, plx_pack_color(1.0f, 0.0f, 0.0f, 1.0f)); // Top Right Of The Quad (Left)
	    
		// Right Face of Box (VIOLET)
		plx_vert_inpm3(PLX_VERT, 1, -1, 1, plx_pack_color(1.0f, 1.0f, 0.0f, 1.0f));     // Bottom Left Of The Quad (Right)
	    plx_vert_inpm3(PLX_VERT, 1, 1, 1, plx_pack_color(1.0f, 1.0f, 0.0f, 1.0f));      // Top Left Of The Quad (Right)
	    plx_vert_inpm3(PLX_VERT, 1, -1, -1, plx_pack_color(1.0f, 1.0f, 0.0f, 1.0f));    // Bottom Right Of The Quad (Right)
	    plx_vert_inpm3(PLX_VERT_EOS, 1, 1, -1, plx_pack_color(1.0f, 1.0f, 0.0f, 1.0f)); // Top Right Of The Quad (Right)

		pvr_scene_finish();
		
		rquad -= 2.0f;  // Increases the box's rotation angle
		rtri += 2.0f;   // Increases the pyramid's rotation angle
    }

	return 0;
}
Esempio n. 11
0
int main(int argc,char **argv){
	Init();
	//sndoggvorbis_start("/pc/billy.ogg",-1);
	Lights[0].z = 10.0;
	Lights[0].x = 0.0;
	Lights[0].y = 0.0;
	Lights[0].w = 1.0;
	Lights[0].r = 5.0;
	Lights[0].g = 0.0;
	Lights[0].b = 0.0;
	Lights[0].a = 1.0;
	Lights[0].aa = 0.0;
	Lights[0].ab = 0.0;
	Lights[0].ac = 1.0;
	Lights[0].dummy = 1.0;
	
	Lights[1].z = 10.0;
	Lights[1].x = 100.0;
	Lights[1].y = 100.0;
	Lights[1].w = 1.0;
	Lights[1].r = 0.0;
	Lights[1].g = 5.0;
	Lights[1].b = 0.0;
	Lights[1].a = 1.0;
	Lights[1].aa = 0.0;
	Lights[1].ab = 0.0;
	Lights[1].ac = 1.0;
	Lights[1].dummy = 1.0;
	
	Lights[2].z = 10.0;
	Lights[2].x = 400.0;
	Lights[2].y = 400.0;
	Lights[2].w = 1.0;
	Lights[2].r = 0.0;
	Lights[2].g = 0.0;
	Lights[2].b = 5.0;
	Lights[2].a = 1.0;
	Lights[2].aa = 0.0;
	Lights[2].ab = 0.0;
	Lights[2].ac = 1.0;
	Lights[2].dummy = 1.0;

	
	vid_border_color(255,0,0);
	Load_Texture("/rd/bumpmap.raw",&GlobalNormal);
	Load_Texture("/rd/text.raw",&GlobalTex);
	vid_border_color(0,0,255);
	Init_Layer();
	
	
	
	int q = 0;
	int x = 0;
	int pushed = 0;
	int bumpenabled = 1;
	int display_fps = 0;
	bfont_set_encoding(BFONT_CODE_ISO8859_1);
	while(q == 0){
		mat_identity();

		
		vid_border_color(255,0,0);
		pvr_wait_ready();
		vid_border_color(0,255,0);
		pvr_scene_begin();
		pvr_list_begin(PVR_LIST_OP_POLY);
			Draw_Layer();
		pvr_list_finish();
		
		pvr_list_begin(PVR_LIST_TR_POLY);
		if(bumpenabled)
			Draw_Layer_Bump();
		pvr_list_finish();
		
		pvr_scene_finish();
		vid_border_color(0,0,255);
	
		MAPLE_FOREACH_BEGIN(MAPLE_FUNC_CONTROLLER, cont_state_t, st);
			if(st->buttons & CONT_START)
				q = 1;
			
			if(st->joyx > 32){
				Lights[x].x += 4.0f;
			}
			if(st->joyx < -32){
				Lights[x].x -= 4.0f;
			}
			if(st->joyy < -32){
				Lights[x].y -= 4.0f;
			}
			if(st->joyy > 32){
				Lights[x].y += 4.0f;
			}
			
			
			if(st->buttons & CONT_DPAD_LEFT){
				Lights[x].x -= 4.0f;
			}
			if(st->buttons & CONT_DPAD_RIGHT){
				Lights[x].x += 4.0f;
			}
			if(st->buttons & CONT_DPAD_UP){
				Lights[x].y -= 4;
			}
			if(st->buttons & CONT_DPAD_DOWN){
				Lights[x].y += 4;
			}
				
			if(st->buttons & CONT_A && pushed == 0){
				pushed = 1;
				x++;
				if(x == LIGHTS){
					x = 0;
				}
			} 
			
			if(st->buttons & CONT_Y && pushed == 0){
				LIGHTS--;
				pushed = 1;
				if(LIGHTS < 0){
					LIGHTS = MAX_LIGHTS;
				}
			}
			
			if(st->buttons & CONT_B && pushed == 0){
				display_fps ^= 0x01;
				pushed = 1;
			}
			
			if(st->buttons & CONT_X && pushed == 0){
				bumpenabled ^= 0x01;
				pushed = 1;
			}
			
			if(!(st->buttons & CONT_A) && !(st->buttons & CONT_B) && !(st->buttons & CONT_X) && !(st->buttons & CONT_Y)){
				pushed = 0;
			}
			
		
		MAPLE_FOREACH_END();
		running_stats();
		sprintf(buf,"FPS:%f",avgfps);
		if(display_fps){
				//printf("%s\n",buf);
			bfont_draw_str(vram_s + (640*24),640,1,buf);
		}
		
	}
	DeleteTexture(&GlobalNormal);
	DeleteTexture(&GlobalTex);
	//sndoggvorbis_stop();
	//sndoggvorbis_shutdown();
	pvr_shutdown();
	return 0;
}
Esempio n. 12
0
int main(int argc, char **argv) {

    /* Controller Stuff */
    maple_device_t * dev;
    cont_state_t * state;

    Model *pModel = NULL;	// Holds The Model Data
    float  yrot = 0.0f;		// Y Rotation

    /* vector_t defined in C:\cygwin\usr\local\dc\kos\kos\addons\include\kos\vector.h */
    /* Holds 3 floats */
    vector_t eye = {75.0f, 75.0f, 75.0f};
    vector_t center = {0.0f, 0.0f, 0.0f};
    vector_t up = {0.0f, 1.0f, 0.0f};

    /* Init PVR API */
    if (pvr_init(&params) < 0)
        return -1;

    printControls();

    /* Sets the background color to black */
    pvr_set_bg_color(0.0f, 0.0f, 0.0f);

    /* Load the model */
    pModel = new MilkshapeModel();
    if ( pModel->loadModelData( "/rd/model.ms3d" ) == false )		// Loads The Model And Checks For Errors
    {
        printf("Couldn't load the model data /rd/model.ms3d \n");
        return 0;													// If Model Didn't Load Quit
    }

    // GET SOME 3D GOING!!
    plx_mat3d_init();                    /* Clear internal to an identity matrix */
    plx_mat3d_mode(PLX_MAT_PROJECTION);  /** Projection (frustum, screenview) matrix */
    plx_mat3d_identity();                /** Load an identity matrix */
    plx_mat3d_perspective(45.0f, 640.0f / 480.0f, 0.1f, 1000.0f);  // (float angle, float aspect, float znear, float zfar);
    plx_mat3d_mode(PLX_MAT_MODELVIEW);   /** Modelview (rotate, scale) matrix */

    pModel->reloadTextures();	// Loads Model Textures

    while(1) {

        /* Check key status */
        dev = maple_enum_dev(0, 0);
        if(dev == NULL) {
            printf("Error: Could not find controller in first port.\n");
            break;
        }
        state = (cont_state_t *)maple_dev_status(dev);
        if (state->buttons & CONT_START) {
            break;           // exit the program
        }

        pvr_wait_ready();
        pvr_scene_begin();
        pvr_list_begin(PVR_LIST_OP_POLY);

        plx_mat3d_identity();
        plx_mat3d_lookat(&eye,&center,&up);  /* Do a camera "look at" */
        plx_mat3d_rotate(yrot, 0.0f, 1.0f, 0.0f);  /* Rotate the model by 'yrot' degrees on the Y-Axis */

        /* Clear internal to an identity matrix */
        plx_mat_identity();

        /* "Apply" all matrices */
        plx_mat3d_apply_all();

        /* Draw the Model */
        pModel->draw();

        pvr_scene_finish();

        yrot += 1.0f;	// Increase the 'yrot' angle
    }
    // Clean Up!!!
    pModel->destroyModel();

    return 0;
}
Esempio n. 13
0
int main(int argc, char **argv) {
    
    /* Controller Stuff */
    maple_device_t * dev;
    cont_state_t * state;
    
    int x, y;
    float xrot = 0;	/* X Rotation */
    float yrot = 0;	/* Y Rotation */
    float zrot = 0;	/* Z Rotation */
    float points[45][45][3];    // The Array For The Points On The Grid Of Our "Wave"
    int wiggle_count = 0;		// Counter Used To Control How Fast Flag Waves
    float hold;					// Temporarily Holds A Floating Point Value
    
    uint32 color = plx_pack_color(1.0f, 1.0f, 1.0f, 1.0f);  // Pure white color.  Used for images to keep original color
    plx_texture_t *a_texture;  // Storage for 1 texture
    
    float float_x, float_y, float_xb, float_yb;       // loop counters.
    
	/* Init PVR API */
	if (pvr_init(&params) < 0)
		return -1;

    printControls();

    /* Sets the background color to blue */
	pvr_set_bg_color(0.0f, 0.0f, 1.0f);
	
	/* Load the texture */
	a_texture = plx_txr_load("/rd/tim.png", 0, PVR_TXRLOAD_16BPP);
	
	plx_cxt_init();                  // Initialize the plx context system
	plx_cxt_texture(a_texture);      // Texture 'a_texture' will be used with the context system 
    plx_cxt_culling(PLX_CULL_NONE);  // No culling
	
	// GET SOME 3D GOING!!
	plx_mat3d_init();                    /* Clear internal to an identity matrix */
	plx_mat3d_mode(PLX_MAT_PROJECTION);  /** Projection (frustum, screenview) matrix */
	plx_mat3d_identity();                /** Load an identity matrix */
	plx_mat3d_perspective(45.0f, 640.0f / 480.0f, 0.1f, 100.0f);  // (float angle, float aspect, float znear, float zfar);
	plx_mat3d_mode(PLX_MAT_MODELVIEW);   /** Modelview (rotate, scale) matrix */
	
	for(float_x = 0.0f; float_x < 9.0f; float_x +=  0.2f )	{
	    for(float_y = 0.0f; float_y < 9.0f; float_y += 0.2f)		{
	        points[ (int) (float_x*5) ][ (int) (float_y*5) ][0] = float_x - 4.4f;
	        points[ (int) (float_x*5) ][ (int) (float_y*5) ][1] = float_y - 4.4f;
	        points[ (int) (float_x*5) ][ (int) (float_y*5) ][2] = (float) (fsin( ( (float_x*5*8)/360 ) * 3.14159 * 2));
	    }
    }
	
	while(1) {
        
        // Check for the user pressing START
		dev = maple_enum_dev(0, 0);
		if(dev == NULL) {
            printf("Error: Could not find controller in first port.\n");
            break;
        }
	    state = (cont_state_t *)maple_dev_status(dev);
	    if (state->buttons & CONT_START) {
		    break;           // exit the program
        }          
		
		pvr_wait_ready();
		pvr_scene_begin();
		pvr_list_begin(PVR_LIST_OP_POLY);
     	
		// Submit the context
		plx_cxt_send(PVR_LIST_OP_POLY);     // Submit the Header for PVR_LIST_OP_POLY 
		
        // DRAW THE BOX	
        plx_mat3d_identity();
	    plx_mat3d_translate(0.0f, 0.0f, -12.0f);  // Move 12 units into the screen
	    plx_mat3d_rotate(xrot, 1.0f, 0.0f, 0.0f); // Rotate the Wavy texture angle 'xrot' on the X axis  
	    plx_mat3d_rotate(yrot, 0.0f, 1.0f, 0.0f); // Rotate the Wavy texture angle 'yrot' on the Y axis  
	    plx_mat3d_rotate(zrot, 0.0f, 0.0f, 1.0f); // Rotate the Wavy texture angle 'zrot' on the Z axis  
	    
	    /* Clear internal to an identity matrix */
	    plx_mat_identity();
	    
    	/* "Applying" all matrixs: multiply a matrix onto the "internal" one */
        plx_mat3d_apply_all();
	    
        // Draw each section of the image
    	for (x = 0; x < 44; x++) {
	        for (y = 0; y < 44; y++) {
	            float_x  = (float) (x)/44;
	            float_y  = (float) (y)/44;
	            float_xb = (float) (x+1)/44;
	            float_yb = (float) (y+1)/44;
             
                plx_vert_ifpm3(PLX_VERT, points[x][y+1][0], points[x][y+1][1], points[x][y+1][2], color, float_x, float_yb);         
                plx_vert_ifpm3(PLX_VERT, points[x][y][0], points[x][y][1], points[x][y][2], color, float_x, float_y);                
                plx_vert_ifpm3(PLX_VERT, points[x+1][y+1][0], points[x+1][y+1][1], points[x+1][y+1][2], color, float_xb, float_yb);  
                plx_vert_ifpm3(PLX_VERT_EOS, points[x+1][y][0], points[x+1][y][1], points[x+1][y][2], color, float_xb, float_y);     
	        }
        }

		pvr_scene_finish();
        
        
        if (wiggle_count == 2) {            // Used To Slow Down The Wave (Every 2nd Frame Only)
	        for( y = 0; y < 45; y++ )		// Loop Through The Y Plane
		    {
			    hold = points[0][y][2];		// Store Current Value One Left Side Of Wave
			    for( x = 0; x < 44; x++)	// Loop Through The X Plane
			    {
				    // Current Wave Value Equals Value To The Right
				    points[x][y][2] = points[x+1][y][2];
			    }
			    points[44][y][2] = hold;	// Last Value Becomes The Far Left Stored Value
		    }
		    wiggle_count = 0;				// Set Counter Back To Zero
    	}
	    wiggle_count++;						// Increase The Counter

        xrot += 0.3f;  // Increase the Wavy Texture's angle(x-axis) rotation
        yrot += 0.2f;  // Increase the Wavy Texture's angle(y-axis) rotation
        zrot += 0.4f;  // Increase the Wavy Texture's angle(z-axis) rotation
    }
    // Clean up!!!
    plx_txr_destroy(a_texture);
    
	return 0;
}
Esempio n. 14
0
int main(int argc,char** argv){
	pvr_vertex_t v;
	Texture spr;
	pvr_poly_cxt_t p_cxt;
	pvr_poly_hdr_t p_hdr;
	
	Init();
	
	Load_VQTexture("/rd/billy.kmg",&spr);
	
	sndoggvorbis_start("/rd/billy.ogg",-1);
	int q = 0;
	while(q == 0){
		vid_border_color(255,0,0);
		pvr_wait_ready();
		vid_border_color(0,255,0);
		pvr_scene_begin();
		
		pvr_list_begin(PVR_LIST_OP_POLY);
		
		pvr_list_finish();
		
		pvr_list_begin(PVR_LIST_TR_POLY);
	
		pvr_poly_cxt_txr(&p_cxt,PVR_LIST_TR_POLY,spr.fmt,spr.w,spr.h,spr.txt,PVR_FILTER_BILINEAR);
		pvr_poly_compile(&p_hdr,&p_cxt);
		pvr_prim(&p_hdr,sizeof(p_hdr)); // submit header
		
		v.x = 0.0;
		v.y = 0.0;
		v.z = 1.0;
		v.u = 0.0;
		v.v = 0.0;
		v.argb = 0xffffffff;
		v.oargb = 0;
		v.flags = PVR_CMD_VERTEX;
		pvr_prim(&v,sizeof(v));
		
		
		v.x = 640.0;
		v.y = 0.0;
		v.u = 1.0;
		v.v = 0.0;
		pvr_prim(&v,sizeof(v));
		
		v.x = 0.0;
		v.y = 480.0;
		v.u = 0.0;
		v.v = 1.0;
		pvr_prim(&v,sizeof(v));
		
		v.x = 640.0;
		v.y = 480.0;
		v.u = 1.0;
		v.v = 1.0;
		v.flags = PVR_CMD_VERTEX_EOL;
		pvr_prim(&v,sizeof(v));
		pvr_list_finish();
		pvr_scene_finish();
		vid_border_color(0,0,255);
		
		
		MAPLE_FOREACH_BEGIN(MAPLE_FUNC_CONTROLLER, cont_state_t, st);
		
			if(st->buttons & CONT_START)
				q = 1;
		
		MAPLE_FOREACH_END();
		
	}
	
	DeleteTexture(&spr);
	
	sndoggvorbis_stop();
	pvr_shutdown();
	sndoggvorbis_shutdown();
	return 0;
}
void do_frame() {
    pvr_vertex_t * vert;
    int x, y, z;
    int i, col;
    int seed = oldseed;
    pvr_dr_state_t dr_state;

#define nextnum() seed = seed * 1164525 + 1013904223;
#define getnum(mn) (seed & ((mn) - 1))

    vid_border_color(0, 0, 0);
    pvr_wait_ready();
    vid_border_color(255, 0, 0);
    pvr_scene_begin();
    pvr_list_begin(PVR_LIST_OP_POLY);
    pvr_prim(&hdr, sizeof(hdr));

    pvr_dr_init(dr_state);

    x = getnum(1024);
    nextnum();
    y = getnum(512);
    nextnum();
    z = getnum(128) + 1;
    nextnum();
    col = getnum(256);
    nextnum();

    vert = pvr_dr_target(dr_state);
    vert->flags = PVR_CMD_VERTEX;
    vert->x = x;
    vert->y = y;
    vert->z = z;
    vert->u = vert->v = 0.0f;
    vert->argb = col | (col << 8) | (col << 16) | 0xff000000;
    vert->oargb = 0;
    pvr_dr_commit(vert);

    for(i = 0; i < polycnt; i++) {
        x = (x + ((getnum(64)) - 32)) & 1023;
        nextnum();
        y = (y + ((getnum(64)) - 32)) % 511;
        nextnum();
        col = getnum(256);
        nextnum();
        vert = pvr_dr_target(dr_state);
        vert->flags = PVR_CMD_VERTEX;
        vert->x = x;
        vert->y = y;
        vert->z = z;
        vert->u = vert->v = 0.0f;
        vert->argb = col | (col << 8) | (col << 16) | 0xff000000;
        vert->oargb = 0;

        if(i == (polycnt - 1))
            vert->flags = PVR_CMD_VERTEX_EOL;

        pvr_dr_commit(vert);
    }

    pvr_list_finish();
    pvr_scene_finish();
    vid_border_color(0, 255, 0);
    oldseed = seed;
}
Esempio n. 16
0
int main(int argc, char **argv) {
    
    /* Controller Stuff */
    maple_device_t * dev;
    cont_state_t * state;
    int xp = 0;    // False (True or False: Pressed X button last) Toggles Filtering
    int yp = 0;    // False (True or False: Pressed Y button last) Toggles Transparency
    int blend = 0; // blending on/off
    
    float x_m, y_m, z_m, u_m, v_m;
    float xtrans, ztrans, ytrans;
    float sceneroty;
    int numtriangles;
    
    int filter = 0;   // texture filtering method to use (NONE or BILINEAR)
    uint32 color = plx_pack_color(0.5f, 1.0f, 1.0f, 1.0f);

	/* Init PVR API */
	if (pvr_init(&params) < 0)
		return -1;
		
	printControls();	
    
    /* Sets the background color to black */
	pvr_set_bg_color(0.0f, 0.0f, 0.0f);

	/* load our world from romdisk */
    SetupWorld();
	
	/* Load the textures */
	textures[0] = plx_txr_load("/rd/mud.png", 0, PVR_TXRLOAD_16BPP | PVR_TXRLOAD_INVERT_Y);  
	textures[1] = plx_txr_load("/rd/mud.png", 0, PVR_TXRLOAD_16BPP | PVR_TXRLOAD_INVERT_Y);  

	plx_cxt_init();                 // Initialize the plx context system
    plx_cxt_culling(PLX_CULL_NONE); // No culling
	
	// GET SOME 3D GOING!!
	plx_mat3d_init();                    /* Clear internal to an identity matrix */
	plx_mat3d_mode(PLX_MAT_PROJECTION);  /** Projection (frustum, screenview) matrix */
	plx_mat3d_identity();                /** Load an identity matrix */
	plx_mat3d_perspective(45.0f, 640.0f / 480.0f, 0.1f, 100.0f);  // (float angle, float aspect, float znear, float zfar);
	plx_mat3d_mode(PLX_MAT_MODELVIEW);   /** Modelview (rotate, scale) matrix */
	
	/* Set the filters for each texture */
	plx_txr_setfilter(textures[0], PLX_FILTER_NONE);
	plx_txr_setfilter(textures[1], PLX_FILTER_BILINEAR);
	
	while(1) {
             
        /* Check key status */
		dev = maple_enum_dev(0, 0);
	    if(dev == NULL) {
            printf("Error: Could not find controller in first port.\n");
            break;
        }
        state = (cont_state_t *)maple_dev_status(dev);
	    if (state->buttons & CONT_START) {
            break;           // exit the program
        }   
        if (state->buttons & CONT_X && !xp) {
            xp = 1;           
            filter += 1;     // Toggle Filter 
            if (filter > 1)
                filter = 0;
        } 
        if (!(state->buttons & CONT_X)) {
            xp = 0;
        }
        if (state->buttons & CONT_Y && !yp) {
            yp = 1;
            blend = !blend;  // Toggle Blending
        } 
        if (!(state->buttons & CONT_Y)) {
            yp = 0;
        }
        if (state->buttons & CONT_A) {
            lookupdown -= 1.0f;  // look up
        } 
        if (state->buttons & CONT_B) {
            lookupdown += 1.0f;  // look down
        } 
        if (state->buttons & CONT_DPAD_UP) {
            xpos -= fsin(yrot*piover180) * 0.05f;  // moves you forward(bobbing head)
            zpos -= fcos(yrot*piover180) * 0.05f;	
            if (walkbiasangle >= 359.0f) {
                walkbiasangle = 0.0f;	
            } else {
                walkbiasangle += 10.0f;
            }
            walkbias = fsin(walkbiasangle * piover180)/20.0f;
        } 
        if (state->buttons & CONT_DPAD_DOWN) {
            xpos += fsin(yrot*piover180) * 0.05f;  // moves you backward(bobbing head)
            zpos += fcos(yrot*piover180) * 0.05f;	
            if (walkbiasangle <= 1.0f) {
                walkbiasangle = 359.0f;	
            } else {
                walkbiasangle -= 10.0f;
            }
            walkbias = fsin(walkbiasangle * piover180)/20.0f;
        }   
        if (state->buttons & CONT_DPAD_LEFT) {
            yrot += 1.5f;    // Turn Left
        } 
        if (state->buttons & CONT_DPAD_RIGHT) {
            yrot -= 1.5f;	  // Turn Right   
        }         
                 
		pvr_wait_ready();
		pvr_scene_begin();
		
	    if(blend) {
		    pvr_list_begin(PVR_LIST_TR_POLY);
		    plx_cxt_send(PVR_LIST_TR_POLY);     // Submit the Header for PVR_LIST_TR_POLY
        } else {
            pvr_list_begin(PVR_LIST_OP_POLY);
		    plx_cxt_send(PVR_LIST_OP_POLY);     // Submit the Header for PVR_LIST_OP_POLY 
        }
		
		/* Select texture according to filter */
		plx_cxt_texture(textures[filter]);
		
	    xtrans = -xpos;   // Used For Player Translation On The X Axis    
        ztrans = -zpos;   // Used For Player Translation On The Z Axis
        ytrans = -walkbias - 0.25f;  // Used For Bouncing Motion Up And Down
        sceneroty = 360.0f - yrot;   // 360 Degree Angle For Player Direction
        
        plx_mat3d_identity();                                           
        plx_mat3d_rotate(lookupdown, 1.0f, 0.0f, 0.0f); // Rotate Up And Down To Look Up And Down             
        plx_mat3d_rotate(sceneroty, 0.0f, 1.0f, 0.0f);  // Rotate Depending On Direction Player Is Facing 
        plx_mat3d_translate(xtrans, ytrans, ztrans);    // Translate The Scene Based On Player Position          
	    
        /* Clear internal to an identity matrix */
        plx_mat_identity();
	    
	    /* "Applying" all matrixs: multiply a matrix onto the "internal" one */
        plx_mat3d_apply_all();
		    
		numtriangles = sector1.numtriangles;    
	
        for (loop = 0; loop < numtriangles; loop++) {        // loop through all the triangles
 
	        // Vertex 1
	        x_m = sector1.triangle[loop].vertex[0].x;
	        y_m = sector1.triangle[loop].vertex[0].y;
	        z_m = sector1.triangle[loop].vertex[0].z;
	        u_m = sector1.triangle[loop].vertex[0].u;
	        v_m = sector1.triangle[loop].vertex[0].v;
	        plx_vert_ifpm3(PLX_VERT, x_m, y_m, z_m, color, u_m, v_m);
	        
	        // Vertex 2
	        x_m = sector1.triangle[loop].vertex[1].x;
	        y_m = sector1.triangle[loop].vertex[1].y;
	        z_m = sector1.triangle[loop].vertex[1].z;
	        u_m = sector1.triangle[loop].vertex[1].u;
	        v_m = sector1.triangle[loop].vertex[1].v;
	        plx_vert_ifpm3(PLX_VERT, x_m, y_m, z_m, color, u_m, v_m);
	        
	         // Vertex 3
	        x_m = sector1.triangle[loop].vertex[2].x;
	        y_m = sector1.triangle[loop].vertex[2].y;
	        z_m = sector1.triangle[loop].vertex[2].z;
	        u_m = sector1.triangle[loop].vertex[2].u;
	        v_m = sector1.triangle[loop].vertex[2].v;
	        plx_vert_ifpm3(PLX_VERT_EOS, x_m, y_m, z_m, color, u_m, v_m);
	        
        }
        pvr_scene_finish();      
    }
    // Clean up!!!
    free(sector1.triangle);
    plx_txr_destroy(textures[0]);
    plx_txr_destroy(textures[1]);
    
	return 0;
}