void Init(){ /* Standard initialization */ vid_set_mode(DM_640x480,PM_RGB565); vid_border_color(0,255,0); //pvr_init_defaults(); pvr_init_params_t pvr_params; pvr_params.vertex_buf_size= 1024*512; pvr_params.dma_enabled= 0; pvr_params.fsaa_enabled= 0; pvr_params.autosort_disabled = 0; pvr_params.opb_sizes[PVR_LIST_OP_POLY]= PVR_BINSIZE_32; pvr_params.opb_sizes[PVR_LIST_OP_MOD]= PVR_BINSIZE_0; pvr_params.opb_sizes[PVR_LIST_TR_POLY]= PVR_BINSIZE_16; pvr_params.opb_sizes[PVR_LIST_TR_MOD]= PVR_BINSIZE_0; pvr_params.opb_sizes[PVR_LIST_PT_POLY]= PVR_BINSIZE_0; pvr_init(&pvr_params); //Set palette to ARGB8888 format pvr_set_pal_format(PVR_PAL_ARGB8888); mat_identity(); //Initialize ogg streamer //snd_stream_init(); //sndoggvorbis_init(); }
int main(int argc, char **argv) { /* Initialize KOS */ pvr_init(¶ms); printf("bullet test beginning\n"); /* Get basic stuff initialized */ glKosInit(); glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); Logger::log("init..\n"); InitScene(); myTimer.start(); Logger::log("go\n"); mGamepad = new Gamepad(); while(1) { mGamepad->Update(); if(mGamepad->Button(GAMEPAD_BTN_START)) break; /* Begin frame */ glKosBeginFrame(); UpdatePhysics(); if (myTimer.getNumUpdates()%120==0) { printf("fps: %.4f\n",myTimer.getNumUpdates()/myTimer.totalSeconds()); printf("fps (immediate): %.4f\n",1.0/myTimer.lastUpdateSeconds()); } // printf("cam: %f,%f,%f\n",myCamera.position.x,myCamera.position.y,myCamera.position.z); // printf("target: %f,%f,%f\n",targetObj.controller().position.x,targetObj.controller().position.y,targetObj.controller().position.z); //printf("obj: %f,%f,%f\n",myRigidSceneObj.controller().position.x,myRigidSceneObj.controller().position.y,myRigidSceneObj.controller().position.z); /* Draw the "scene" */ draw_gl(); /* Finish the frame */ glKosFinishFrame(); } return 0; }
void setup() { pvr_poly_cxt_t cxt; pvr_init(&pvr_params); pvr_set_bg_color(0,0,0); pvr_poly_cxt_col(&cxt, PVR_LIST_OP_POLY); cxt.gen.shading = PVR_SHADE_FLAT; pvr_poly_compile(&hdr, &cxt); }
void setup() { pvr_init(&pvr_params); glKosInit(); pvr_set_bg_color(0,0,0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glOrtho(0,640,0,480,-100,100); glMatrixMode(GL_PROJECTION); glLoadIdentity(); }
void init() { /* Kos initialisation */ pvr_init(¶m); /* initialise Kgl */ glKosInit(); initGL(); }
int main() { pvr_init(); pvr2_render_load_scene(stdin); pvr2_render_loaded_scene(); asic_clear(); asic_wait(EVENT_RETRACE); asic_clear(); asic_wait(EVENT_RETRACE); asic_clear(); asic_wait(EVENT_RETRACE); }
/* Simpler function which initializes the PVR using 16/16 for the opaque and translucent lists, and 0's for everything else; 512k of vertex buffer. This is equivalent to the old ta_init_defaults() for now. */ int pvr_init_defaults() { pvr_init_params_t params = { /* Enable opaque and translucent polygons with size 16 */ { PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_0 }, /* Vertex buffer size 512K */ 512*1024, /* No DMA */ 0 }; return pvr_init(¶ms); }
static void init_pvr (void) { pvr_init_params_t params = { { PVR_BINSIZE_16, /* Opaque polygons. */ PVR_BINSIZE_0, /* Opaque modifiers. */ PVR_BINSIZE_0, /* Translucent polygons. */ PVR_BINSIZE_0, /* Translucent modifiers. */ PVR_BINSIZE_16 }, /* Punch-thrus. */ 512 * 1024, /* Vertex buffer size 512K. */ 0, /* No DMA. */ 0 /* No FSAA. */ }; pvr_init (¶ms); }
int main(int argc, char *argv[]) { printf("---KallistiOS PVR Modifier Example (with textures)---\n"); printf("Use the DPAD to move the modifier square around (it starts at "); printf("(320, 240))\n"); printf("Press Start to exit.\n"); srand(time(NULL)); pvr_init(&pvr_params); setup(); /* Go as long as the user hasn't pressed start on controller 1. */ while(!check_start()) { do_frame(); } pvr_mem_free(txr1); pvr_mem_free(txr2); return 0; }
int main(int argc, char **argv) { cont_cond_t cond; uint8 c; /* Get basic stuff initialized */ pvr_init(¶ms); printf("nehe02 beginning\n"); glKosInit(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f,640.0f/480.0f,0.1f,100.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); c = maple_first_controller(); while(1) { /* Check key status */ if (cont_get_cond(c, &cond) < 0) { printf("Error reading controller\n"); break; } if (!(cond.buttons & CONT_START)) break; /* Begin frame */ glKosBeginFrame(); /* Draw the "scene" */ draw_gl(); /* Finish the frame */ glKosFinishFrame(); } return 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(¶ms) < 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; }
SDL_Surface *AN_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags) { int disp_mode,pixel_mode,pitch; Uint32 Rmask, Gmask, Bmask; if (width==320 && height==240) disp_mode=DM_320x240; else if (width==640 && height==480) disp_mode=DM_640x480; else if (width==800 && height==600) disp_mode=DM_800x608; else { SDL_SetError("Couldn't find requested mode in list"); return(NULL); } switch(bpp) { case 15: pixel_mode = PM_RGB555; pitch = width*2; /* 5-5-5 */ Rmask = 0x00007c00; Gmask = 0x000003e0; Bmask = 0x0000001f; break; case 16: pixel_mode = PM_RGB565; pitch = width*2; /* 5-6-5 */ Rmask = 0x0000f800; Gmask = 0x000007e0; Bmask = 0x0000001f; break; case 24: bpp = 32; case 32: pixel_mode = PM_RGB888; pitch = width*4; Rmask = 0x00ff0000; Gmask = 0x0000ff00; Bmask = 0x000000ff; #if SDL_VIDEO_OPENGL if (!(flags & SDL_OPENGL)) #endif break; default: SDL_SetError("Couldn't find requested mode in list"); return(NULL); } // if ( bpp != current->format->BitsPerPixel ) { if ( ! SDL_ReallocFormat(current, bpp, Rmask, Gmask, Bmask, 0) ) { return(NULL); } // } /* Set up the new mode framebuffer */ current->flags = (SDL_FULLSCREEN|SDL_HWSURFACE); current->w = width; current->h = height; current->pitch = pitch; #if SDL_VIDEO_OPENGL if (pvr_inited) { pvr_inited = 0; pvr_shutdown(); } #endif printf("Android set mode %s,%s uimplemeneted\n", __FILE__, __FUNCTION__); //vid_set_mode(disp_mode,pixel_mode); // TODO: SDL_SetError("Android video not unimplemented"); return NULL; current->pixels = NULL; //vram_s; #if SDL_VIDEO_OPENGL if (flags & SDL_OPENGL) { this->gl_config.driver_loaded = 1; current->flags = SDL_FULLSCREEN | SDL_OPENGL; current->pixels = NULL; pvr_inited = 1; pvr_init(¶ms); glKosInit(); glKosBeginFrame(); } else #endif if (flags | SDL_DOUBLEBUF) { current->flags |= SDL_DOUBLEBUF; current->pixels = (void*)((int)current->pixels | 0x400000); } /* We're done */ return(current); }
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(¶ms) < 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; }
static int pvr_stream_open (stream_t *stream, int mode, void *opts, int *file_format) { struct v4l2_capability vcap; struct v4l2_ext_controls ctrls; struct pvr_t *pvr = NULL; if (mode != STREAM_READ) return STREAM_UNSUPPORTED; pvr = pvr_init (); /** * if the url, i.e. 'pvr://8', contains the channel, use it, * else use the tv parameter. */ if (stream->url && strlen (stream->url) > 6 && stream->url[6] != '\0') pvr->param_channel = strdup (stream->url + 6); else if (stream_tv_defaults.channel && strlen (stream_tv_defaults.channel)) pvr->param_channel = strdup (stream_tv_defaults.channel); parse_v4l2_tv_options (pvr); parse_encoder_options (pvr); /* open device */ pvr->dev_fd = open (pvr->video_dev, O_RDWR); mp_msg (MSGT_OPEN, MSGL_INFO, "%s Using device %s\n", LOG_LEVEL_PVR, pvr->video_dev); if (pvr->dev_fd == -1) { mp_msg (MSGT_OPEN, MSGL_ERR, "%s error opening device %s\n", LOG_LEVEL_PVR, pvr->video_dev); pvr_uninit (pvr); return STREAM_ERROR; } /* query capabilities (i.e test V4L2 support) */ if (ioctl (pvr->dev_fd, VIDIOC_QUERYCAP, &vcap) < 0) { mp_msg (MSGT_OPEN, MSGL_ERR, "%s device is not V4L2 compliant (%s).\n", LOG_LEVEL_PVR, strerror (errno)); pvr_uninit (pvr); return STREAM_ERROR; } else mp_msg (MSGT_OPEN, MSGL_INFO, "%s Detected %s\n", LOG_LEVEL_PVR, vcap.card); /* check for a valid V4L2 capture device */ if (!(vcap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) { mp_msg (MSGT_OPEN, MSGL_ERR, "%s device is not a valid V4L2 capture device.\n", LOG_LEVEL_PVR); pvr_uninit (pvr); return STREAM_ERROR; } /* check for device hardware MPEG encoding capability */ ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG; ctrls.count = 0; ctrls.controls = NULL; if (ioctl (pvr->dev_fd, VIDIOC_G_EXT_CTRLS, &ctrls) < 0) { mp_msg (MSGT_OPEN, MSGL_ERR, "%s device do not support MPEG input.\n", LOG_LEVEL_ENCODER); return STREAM_ERROR; } /* list V4L2 capabilities */ if (v4l2_list_capabilities (pvr) == -1) { mp_msg (MSGT_OPEN, MSGL_ERR, "%s can't get v4l2 capabilities\n", LOG_LEVEL_PVR); pvr_uninit (pvr); return STREAM_ERROR; } /* apply V4L2 settings */ if (set_v4l2_settings (pvr) == -1) { mp_msg (MSGT_OPEN, MSGL_ERR, "%s can't set v4l2 settings\n", LOG_LEVEL_PVR); pvr_uninit (pvr); return STREAM_ERROR; } /* apply encoder settings */ if (set_encoder_settings (pvr) == -1) { mp_msg (MSGT_OPEN, MSGL_ERR, "%s can't set encoder settings\n", LOG_LEVEL_PVR); pvr_uninit (pvr); return STREAM_ERROR; } /* display current V4L2 settings */ if (v4l2_display_settings (pvr) == -1) { mp_msg (MSGT_OPEN, MSGL_ERR, "%s can't get v4l2 settings\n", LOG_LEVEL_PVR); pvr_uninit (pvr); return STREAM_ERROR; } stream->priv = pvr; stream->type = STREAMTYPE_PVR; stream->fill_buffer = pvr_stream_read; stream->close = pvr_stream_close; return STREAM_OK; }
int main(int argc, char **argv) { cont_cond_t cond; uint8 c; GLboolean yp = GL_FALSE; /* Initialize KOS */ pvr_init(¶ms); printf("nehe09 beginning\n"); /* Get basic stuff initialized */ glKosInit(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f,640.0f/480.0f,0.1f,100.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.5f); glClearDepth(1.0f); glBlendFunc(GL_SRC_ALPHA,GL_ONE); //glEnable(GL_BLEND); for (loop=0; loop<NUM_STARS; loop++) { star[loop].angle=0.0f; star[loop].dist=((float)(loop)/NUM_STARS)*5.0f; star[loop].r=rand()%256; star[loop].g=rand()%256; star[loop].b=rand()%256; } /* Set up the texture */ loadtxr("/rd/Star.pcx", &texture[0]); c = maple_first_controller(); while(1) { /* Check key status */ if (cont_get_cond(c, &cond) < 0) { printf("Error reading controller\n"); break; } if (!(cond.buttons & CONT_START)) break; if (!(cond.buttons & CONT_DPAD_UP)) tilt -= 0.5f; if (!(cond.buttons & CONT_DPAD_DOWN)) tilt += 0.5f; if (!(cond.buttons & CONT_A)) zoom -= 0.2f; if (!(cond.buttons & CONT_B)) zoom += 0.2f; if (!(cond.buttons & CONT_Y) && !yp) { yp = GL_TRUE; twinkle = !twinkle; } if (cond.buttons & CONT_Y) yp = GL_FALSE; /* Begin frame */ glKosBeginFrame(); /* Switch to blended polygon list */ glKosFinishList(); /* Draw the GL "scene" */ draw_gl(); /* Finish the frame */ glKosFinishFrame(); } return 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(¶ms) < 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,¢er,&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; }
int main(int argc, char **argv) { cont_cond_t cond; uint8 c; int trans = 0; GLuint texture1, texture2, texture3; /* Initialize KOS */ pvr_init(¶ms); printf("texenv beginning\n"); /* Get basic stuff initialized */ glKosInit(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glOrtho(0,640,0,480,0,-1); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glEnable(GL_TEXTURE_2D); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthMask(GL_FALSE); /* Set up the textures */ loadtxr("/rd/checker.pcx", &texture1); loadtxr("/rd/crate.pcx", &texture2); loadtxr_tga("/rd/kgl.tga", &texture3); c = maple_first_controller(); while(1) { /* Check key status */ if (cont_get_cond(c, &cond) < 0) { printf("Error reading controller\n"); break; } if (!(cond.buttons & CONT_START)) break; if (!(cond.buttons & CONT_A)) { /* This weird logic is to avoid bouncing back and forth before the user lets go of the button. */ if (!(trans & 0x1000)) { if (trans == 0) trans = 0x1001; else trans = 0x1000; } } else { trans &= ~0x1000; } /* Begin frame */ glKosBeginFrame(); glDisable(GL_KOS_AUTO_UV); glBindTexture(GL_TEXTURE_2D, texture1); glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_REPLACE); glColor4f(0,0,0,0); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex3f(0,0,0); glTexCoord2f(20,0); glVertex3f(640,0,0); glTexCoord2f(20,15); glVertex3f(640,480,0); glTexCoord2f(0,15); glVertex3f(0,480,0); glEnd(); if (trans & 1) { glKosFinishList(); } /* top row, non-alpha texture */ glEnable(GL_KOS_AUTO_UV); glBindTexture(GL_TEXTURE_2D, texture2); glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_REPLACE); quad(5,250); glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE); quad(165,250); glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_DECAL); quad(325,250); glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATEALPHA); quad(485,250); /* bottom row, alpha texture */ glBindTexture(GL_TEXTURE_2D, texture3); glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_REPLACE); quad(5,50); glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE); quad(165,50); glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_DECAL); quad(325,50); glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATEALPHA); quad(485,50); /* Finish the frame */ glKosFinishFrame(); } return 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(¶ms) < 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; }
int main(int argc, char **argv) { cont_cond_t cond; uint8 c; float r = 0.0f; float dr = 2; float z = -14.0f; GLuint texture; GLuint dummy; int trans = 0; pvr_stats_t stats; /* Initialize KOS */ /* Use this to test other video modes */ /* vid_init(DM_320x240, PM_RGB565); */ /* Normal init */ pvr_init(¶ms); printf("gltest beginning\n"); /* Get basic stuff initialized */ glKosInit(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f, 640.0f / 480.0f, 0.1f, 100.0f); glMatrixMode(GL_MODELVIEW); glEnable(GL_TEXTURE_2D); glEnable(GL_KOS_AUTO_UV); /* Expect CW verts */ glFrontFace(GL_CW); /* Enable Transparancy */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* Load a texture and make to look nice */ loadtxr("/rd/crate.pcx", &texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_FILTER, GL_FILTER_BILINEAR); glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATEALPHA); glClearColor(0.3f, 0.4f, 0.5f, 1.0f); while(1) { /* Check key status */ c = maple_first_controller(); if (c) { if (cont_get_cond(c, &cond) < 0) { printf("Error reading controller\n"); } if (!(cond.buttons & CONT_START)) break; if (!(cond.buttons & CONT_DPAD_UP)) z -= 0.1f; if (!(cond.buttons & CONT_DPAD_DOWN)) z += 0.1f; if (!(cond.buttons & CONT_DPAD_LEFT)) { /* If manual rotation is requested, then stop the automated rotation */ dr = 0.0f; r -= 2.0f; } if (!(cond.buttons & CONT_DPAD_RIGHT)) { dr = 0.0f; r += 2.0f; } if (!(cond.buttons & CONT_A)) { /* This weird logic is to avoid bouncing back and forth before the user lets go of the button. */ if (!(trans & 0x1000)) { if (trans == 0) trans = 0x1001; else trans = 0x1000; } } else { trans &= ~0x1000; } } r += dr; /* Begin frame */ glKosBeginFrame(); /* Draw four cubes */ glLoadIdentity(); glTranslatef(0.0f, 0.0f, z); glRotatef(r, 0.0f, 1.0f, 0.5f); glPushMatrix(); glTranslatef(-5.0f, 0.0f, 0.0f); cube(r); glPopMatrix(); glPushMatrix(); glTranslatef(5.0f, 0.0f, 0.0f); cube(r); /* Potentially do two as translucent */ if (trans & 1) { glKosFinishList(); glColor4f(1.0f, 1.0f, 1.0f, 0.5f); glDisable(GL_CULL_FACE); } glPopMatrix(); glPushMatrix(); glTranslatef(0.0f, 5.0f, 0.0f); cube(r); glPopMatrix(); glTranslatef(0.0f, -5.0f, 0.0f); cube(r); if (trans & 1) { glEnable(GL_CULL_FACE); } /* Finish the frame */ glKosFinishFrame(); } pvr_get_stats(&stats); printf("VBL Count: %d, last_time: %f, frame rate: %f fps\n", stats.vbl_count, stats.frame_last_time, stats.frame_rate); return 0; }