void icetProjectTile(GLint tile) { GLint *viewports; GLint physical_viewport[4]; GLint tile_width, tile_height; GLint renderable_width, renderable_height; /* Update tile projections. */ if (viewport_time != icetStateGetTime(ICET_TILE_VIEWPORTS)) { update_tile_projections(); viewport_time = icetStateGetTime(ICET_TILE_VIEWPORTS); } if ((tile < 0) || (tile >= num_tiles)) { icetRaiseError("Bad tile passed to icetProjectTile.", ICET_INVALID_VALUE); return; } viewports = icetUnsafeStateGet(ICET_TILE_VIEWPORTS); tile_width = viewports[tile*4+2]; tile_height = viewports[tile*4+3]; glGetIntegerv(GL_VIEWPORT, physical_viewport); renderable_width = physical_viewport[2]; renderable_height = physical_viewport[3]; if ((renderable_width != tile_width) || (renderable_height != tile_height)){ /* Compensate for fact that tile is smaller than actual window. */ glOrtho(-1.0, 2.0*renderable_width/tile_width - 1.0, -1.0, 2.0*renderable_height/tile_height - 1.0, 1.0, -1.0); } glMultMatrixd(tile_projections + 16*tile); if (projection_time != icetStateGetTime(ICET_PROJECTION_MATRIX)) { icetGetDoublev(ICET_PROJECTION_MATRIX, global_projection); projection_time = icetStateGetTime(ICET_PROJECTION_MATRIX); } glMultMatrixd(global_projection); }
static void update_tile_projections(void) { IceTInt num_tiles; const IceTInt *viewports; IceTDouble *tile_projections; IceTInt tile_idx; if ( icetStateGetTime(ICET_TILE_VIEWPORTS) < icetStateGetTime(ICET_TILE_PROJECTIONS) ) { /* Projections already up to date. */ return; } icetGetIntegerv(ICET_NUM_TILES, &num_tiles); tile_projections = icetStateAllocateDouble(ICET_TILE_PROJECTIONS, num_tiles*16); viewports = icetUnsafeStateGetInteger(ICET_TILE_VIEWPORTS); for (tile_idx = 0; tile_idx < num_tiles; tile_idx++) { icetGetViewportProject(viewports[tile_idx*4+0], viewports[tile_idx*4+1], viewports[tile_idx*4+2], viewports[tile_idx*4+3], tile_projections + 16*tile_idx); } }