void watchpoints_stop_stream() { LOG("wpts: stop stream\r\n"); disable_watchpoints(); swap_buffers(); }
void dump_buffer(uint8_t *buffer, int count) { draw_top_bar(0, (CNTRLDISPLAY){0, 0, 0, 0, 1}); int i, xoffset=4, yoffset=34; char hex_buffer[10]; for (i=0; i<count; i++) { memset(hex_buffer, 0, 10); sstring(hex_buffer, "%x", buffer[i]); putstr_small(xoffset, yoffset, hex_buffer, 1); xoffset += 16; if ((i+1)%16==0) { yoffset += 8; xoffset = 4; } } swap_buffers(); uint16_t key; while (1) { key = get_key(); switch (key) { case ESC_PRESSED: return; } } }
bool PIOS_Vsync_ISR() { static portBASE_TYPE xHigherPriorityTaskWoken; xHigherPriorityTaskWoken = pdFALSE; m_osdLines = gActiveLine; stop_hsync_timers(); // Wait for previous word to clock out of each TIM_Cmd(dev_cfg->pixel_timer.timer, ENABLE); flush_spi(); TIM_Cmd(dev_cfg->pixel_timer.timer, DISABLE); gActiveLine = 0; Hsync_update = 0; Vsync_update++; if (Vsync_update >= 2) { // load second image buffer swap_buffers(); Vsync_update = 0; // trigger redraw every second field xHigherPriorityTaskWoken = xSemaphoreGiveFromISR(osdSemaphore, &xHigherPriorityTaskWoken); } portEND_SWITCHING_ISR(xHigherPriorityTaskWoken); // portEND_SWITCHING_ISR(xHigherPriorityTaskWoken); return xHigherPriorityTaskWoken == pdTRUE; }
void LearnEngine::LearnList::add_sample(const PHV &phv) { static thread_local ByteContainer sample; sample.clear(); builder(phv, &sample); std::unique_lock<std::mutex> lock(mutex); const auto it = filter.find(sample); if(it != filter.end()) return; buffer.insert(buffer.end(), sample.begin(), sample.end()); num_samples++; auto filter_it = filter.insert(filter.end(), std::move(sample)); FilterPtrs &filter_ptrs = old_buffers[buffer_id]; filter_ptrs.unacked_count++; filter_ptrs.buffer.push_back(filter_it); if(num_samples == 1 && max_samples > 1) { buffer_started = clock::now(); b_can_send.notify_one(); // wake transmit thread to update cond var wait time } else if(num_samples >= max_samples) { while(buffer_tmp.size() != 0) { b_can_swap.wait(lock); } swap_buffers(); b_can_send.notify_one(); } }
static EGLBoolean egl_g3d_post_sub_buffer(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint x, EGLint y, EGLint width, EGLint height) { EGLint rect[4]; if (x < 0 || y < 0 || width < 0 || height < 0) return _eglError(EGL_BAD_PARAMETER, "eglPostSubBufferNV"); /* clamp */ if (x + width > surf->Width) width = surf->Width - x; if (y + height > surf->Height) height = surf->Height - y; if (width <= 0 || height <= 0) return EGL_TRUE; rect[0] = x; /* Note: y=0=bottom */ rect[1] = surf->Height - y - height; rect[2] = width; rect[3] = height; return swap_buffers(drv, dpy, surf, 1, rect, EGL_TRUE); }
void broadcast_msg(char *text, char big, unsigned char wait, unsigned char fg, unsigned char bg) { int text_width = (big)?get_str_width_big(text):get_str_width(text); int text_height = (big)?25:16; uint32_t absolute_x = (WIDTH_W/2) - (text_width/2) - 10; uint32_t absolute_y = (HEIGHT_W/2) - (text_height/2) - 10; ashes_palette_dim(); rectangle_filled(absolute_x, absolute_y, text_width + (2*10), text_height + (2*10), bg); if (big) putstr_big(absolute_x + 10, absolute_y + 10, text, fg); else putstr(absolute_x + 10, absolute_y + 10, text, fg); swap_buffers(); if (wait) { uint16_t key; while (1) { key = get_key(); switch (key) { case ENTER_PRESSED: case ESC_PRESSED: ashes_palette(); return; } } } }
void draw_text_prompt(char *text, char *buffer, int max_char) { int buf_loc = strlen(buffer); char prompt[100]; memset(prompt, 0 ,100); sstring(prompt, "%s (%d:%d)", text, buf_loc, max_char); uint32_t prompt_px_width = get_str_width(prompt); uint32_t buffer_px_width = get_str_width_big(buffer); int box_height = 10 + 16 + 10 + 27 + 10; int box_width = ((prompt_px_width+20)>(buffer_px_width+20+10+6))?(prompt_px_width+20):(buffer_px_width+20+10+6); uint32_t absolute_x = (WIDTH_W/2) - (box_width/2); uint32_t absolute_y = (HEIGHT_W/2) - (box_height/2); rectangle_filled(absolute_x, absolute_y, box_width, box_height, 3+8); rectangle_filled(absolute_x+10, absolute_y+26 + 10, box_width - 20, 27, 4+8); putstr((WIDTH_W/2) - (prompt_px_width/2) , absolute_y + 10, prompt, 1+8); putstr_big(absolute_x+14, absolute_y+26 + 10 + 1, buffer, 1+8); putstr_big(absolute_x+14 + buffer_px_width, absolute_y+26 + 10 + 1, "_", 2+8); swap_buffers(); }
void draw_selection_prompt(char *text, char items[][100], int num_items, unsigned int selected) { uint32_t prompt_px_width = get_str_width(text); int i, item_width, selection_width = 0; for (i=0; i<num_items; i++) { item_width = get_str_width_big(items[i]); selection_width = (item_width+10>selection_width)?item_width+10:selection_width; } int box_height = 10 + 16 + 10 + 27 + 10; int box_width = ((prompt_px_width+20)>((selection_width*num_items)+10+(10*num_items)))?(prompt_px_width+20):((selection_width*num_items)+10+(10*num_items)); uint32_t absolute_x = (WIDTH_W/2) - (box_width/2); uint32_t absolute_y = (HEIGHT_W/2) - (box_height/2); rectangle_filled(absolute_x, absolute_y, box_width, box_height, 4+8); putstr((WIDTH_W/2) - (prompt_px_width/2) , absolute_y + 10, text, 1+8); absolute_x += (box_width/2) - (((selection_width*num_items)+10+(10*num_items))/2) + 10; for (i=0; i<num_items; i++) { item_width = get_str_width_big(items[i]); if (i==selected) rectangle_filled(absolute_x, absolute_y + 26 + 10, selection_width, 27, 1+8); putstr_big(absolute_x + (selection_width/2) - (item_width/2), absolute_y + 26 + 10 + 1, items[i], (i==selected)?4+8:3+8); absolute_x += 10 + selection_width; } swap_buffers(); }
void CanvasX11::update() { Options::FrameEnd m = Options::frame_end; if (m == Options::FrameEndDefault) { if (offscreen_) m = Options::FrameEndFinish; else m = Options::FrameEndSwap; } switch(m) { case Options::FrameEndSwap: swap_buffers(); break; case Options::FrameEndFinish: glFinish(); break; case Options::FrameEndReadPixels: read_pixel(width_ / 2, height_ / 2); break; case Options::FrameEndNone: default: break; } }
void display() { unsigned int msec = get_time_msec() - start_time; double t = (double)msec / 1000.0; update(t); glClearColor(0.1, 0.1, 0.1, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0, 0, -8); glFrontFace(GL_CW); glBegin(GL_TRIANGLES); msurf_polygonize(msurf); glEnd(); swap_buffers(); assert(glGetError() == GL_NO_ERROR); if(use_shape) { glReadPixels(0, 0, win_width, win_height, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, stencil); window_shape(stencil, win_width, win_height); } }
static void append_watchpoint_event(unsigned index) { if (watchpoint_events_count[watchpoint_events_buf_idx] < param_num_watchpoint_events_buffered) { watchpoint_event_t *watchpoint_event = &watchpoint_events_buf[watchpoint_events_count[watchpoint_events_buf_idx]++]; watchpoint_event->timestamp = SYSTICK_CURRENT_TIME; watchpoint_event->index = index; if (watchpoints_vcap_snapshot & (1 << index)) watchpoint_event->vcap = ADC_read(ADC_CHAN_INDEX_VCAP); else // TODO: don't stream vcap at all if snapshot is not enabled watchpoint_event->vcap = 0; } if (watchpoint_events_count[watchpoint_events_buf_idx] == param_num_watchpoint_events_buffered) {// buffer full if (!(main_loop_flags & FLAG_WATCHPOINT_READY)) { // the other buffer is free swap_buffers(); // clear error indicator GPIO(PORT_LED, OUT) &= ~BIT(PIN_LED_RED); } else { // both buffers are full // indicate error on LED GPIO(PORT_LED, OUT) |= BIT(PIN_LED_RED); // drop the watchpoints on the floor } } else { // clear error indicator GPIO(PORT_LED, OUT) &= ~BIT(PIN_LED_RED); } }
static EGLBoolean egl_g3d_swap_buffers_region(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint num_rects, const EGLint *rects) { /* Note: y=0=top */ return swap_buffers(drv, dpy, surf, num_rects, rects, EGL_TRUE); }
static EGLBoolean egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) { struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); return swap_buffers(drv, dpy, surf, 0, NULL, (gsurf->base.SwapBehavior == EGL_BUFFER_PRESERVED)); }
void draw_top_bar(uint8_t swap, CNTRLDISPLAY controls) { rectangle_filled(0, 0, 640, 30, 1); rectangle_filled(0, 30, 640, 480-30, 0); draw_glyph(3, 7, spclr_logo_width, spclr_logo_height, spclr_logo, 0, 0); draw_controls(controls); if (swap) swap_buffers(); }
void rt_rtvi_clear(void * voidhandle) { rtvihandle * handle = (rtvihandle *) voidhandle; long x, y; for(y=0; y<SCREEN_HI; y++) { for (x=0; x<SCREEN_WIDE; x++) handle->scanline[handle->flip][x]=0x00000000; put_scanline(y, handle->flip); handle->flip = 1 - handle->flip; } swap_buffers(); for(y=0; y<SCREEN_HI; y++) { for (x=0; x<SCREEN_WIDE; x++) handle->scanline[handle->flip][x]=0x00000000; put_scanline(y, handle->flip); handle->flip = 1 - handle->flip; } swap_buffers(); }
int main(int argv, char argc) { int i; void * handle = rt_rtvi_init(512, 512); for (i=0; i<100; i++) { rt_rtvi_clear(handle); swap_buffers(); printf("# %d \r", i); fflush(stdout); } return 0; }
// DRAW METHOD // OpenGL window: (w,h) is upper right, (-w,-h) is lower left, (0,0) is center // void draw() { // First time? init viewport, etc. if (!valid()) { valid(1); float ratio = 1.0f* w() / h(); // Use the Projection Matrix glMatrixMode(GL_PROJECTION); // Reset Matrix glLoadIdentity(); // Set the viewport to be the entire window glViewport(0, 0, w(), h()); // Set the correct perspective. gluPerspective(45,ratio,1,1000); // Get Back to the Modelview glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(camera.x, camera.y, camera.z, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f); } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_BLEND); glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA); // Draw the floor plane glBegin(GL_QUADS); glColor4f(0.0f, 0.1f, 0.1f, 0.5f); glVertex3f(-10.0f, 0.0f, 10.0f); glVertex3f(10.0f, 0.0f, 10.0f); glVertex3f(10.0f, 0.0f, -10.0f); glVertex3f(-10.0f, 0.0f, -10.0f); glEnd(); particles.Render(&env, camera); glPopMatrix(); swap_buffers(); }
void part1(void) { //int x,y,xa,ya; int a/*,r,g*/,b/*,c,i*/; int frame=0; //char *cp,*dp; frame=0; for(b=0;b<200;b++) { a=b; firfade1a[b]=(19+a/5+4)&(~7); firfade2a[b]=(-(19+(199-a)/5+4))&(~7); firfade1[b]=170*64+(100-b)*50; firfade2[b]=170*64+(100-b)*50; } if(dis_musplus()>-30) while(!dis_exit() && dis_musplus()<-6) ; dis_waitb(); dis_setmframe(0); while(!dis_exit() && frame<300) { if(frame<80) { a=frame*2; #if 0 for(c=0;c<6;c++) { //cp=vram; dp=back; for(y=0;y<200;y++) { x=firfade1[y]>>6; cp[x]=dp[x]; x=firfade2[y]>>6; cp[x]=dp[x]; firfade1[y]+=firfade1a[y]; firfade2[y]+=firfade2a[y]; cp+=320; dp+=320; } } #endif } clear_screen(); float ff = (float)frame / 40; if (ff > 1.0f) ff = 1.0f; draw_fir(ff); swap_buffers(); a=waitb(); frame+=a; }
/* Main rendering function. Note how it's essentially the same as the ones you were writing in OpenGL! We start by clearing the buffer, render some stuff, then swap the buffers. All that's different is some slightly different matrix access. */ void Renderer::RenderScene() { set_viewport(); clear_buffer(); drawSkybox(); //fillBuffers(); //drawPointLights(); //combineBuffers(); simpleLighting(); swap_buffers(); //std::cout << "Not crashed!!" << std::endl; }
int menu_page(MENU menu_element, char menu_items[][100], int num_items, CNTRLDISPLAY controls, uint8_t bg, unsigned int selected) { memset(&menu_element, 0, sizeof(MENU)); menu_element.bg = bg; menu_element.vpad = menu_element.hpad = 10; int i; for (i=0; i<num_items; i++) { MENUITEM *item = &menu_element.items[i]; item->size.height = 25; item->fg = 1; item->selectedfg = 2; item->active = 1; item->selected = (i==selected)?1:0; setup_text(&item->header_text, menu_items[i], (POSITION){0,0}, 1, 0); } uint16_t key; while (1) { draw_top_bar(0, controls); draw_menu(&menu_element); swap_buffers(); key = get_key(); switch (key&0xff) { case DOWN_PRESSED: case RIGHT_PRESSED: selected++; break; case UP_PRESSED: case LEFT_PRESSED: selected--; break; case ENTER_PRESSED: return selected; case ESC_PRESSED: if (controls.esc_back || controls.esc_menu) return -1; break; default: continue; } selected = (selected<0)?num_items-1:selected; selected %= num_items; for (i=0;i<num_items;i++) menu_element.items[i].selected = (i==selected); } }
void WindowBase::display() { if (framerate > 0) { double time = 1.0 / framerate - clock.get_elapsed(); if (time > 0) Clock::sleep(time); } frame = clock.get_elapsed(); clock.reset(); input().swap_buffers(); swap_buffers(); std::ostringstream ss; ss << "fps: " << 1.0 / get_frame_time(); set_caption(ss.str()); }
void draw_gameover(void) { short int ret = load_bmp("GO.BMP", &background_bmp); short int ret1 = load_bmp("CURSOR.BMP", &cursor_bmp); // Draw background to both buffers draw_bmp(background_bmp, 0, 240 - background_bmp->bmp_info_header->height, false, back_alpha, 1); swap_buffers(); draw_box( 90, 90, 110, 110, back_alpha, 1); draw_bmp(background_bmp, 0, 240 - background_bmp->bmp_info_header->height, false, back_alpha, 1); }
static void DisplayNoDrawDoTest(void) { for (global_iteration = 0; global_iteration < global_num_proc; global_iteration++) { IceTImage image; IceTUByte *color_buffer; printf("Blank image is rank %d\n", global_iteration); image = icetGLDrawFrame(); swap_buffers(); if ( (global_rank == 0) && (global_num_proc > 1) /* This last case covers when there is only 2 processes, * the root, as always, is not drawing anything and the * other process is drawing the clear screen. */ && ((global_num_proc > 2) || (global_iteration != 1)) ) { int p; int bad_count = 0; printf("Checking pixels.\n"); color_buffer = icetImageGetColorub(image); for (p = 0; (p < SCREEN_WIDTH*SCREEN_HEIGHT*4) && (bad_count < 10); p++) { if (color_buffer[p] != 255) { printf("BAD PIXEL %d.%d\n", p/4, p%4); printf(" Expected 255, got %d\n", color_buffer[p]); bad_count++; } } if (bad_count >= 10) { char filename[256]; global_result = TEST_FAILED; sprintf(filename, "DisplayNoDraw_%s_%s_%d.ppm", icetGetStrategyName(), icetGetSingleImageStrategyName(), global_iteration); write_ppm(filename, color_buffer, (int)SCREEN_WIDTH, (int)SCREEN_HEIGHT); break; } } } }
void Renderer::renderInitScreen() { this->SetCurrentShader(*basicVert, *basicFrag); Matrix4 aProjMatrix = Matrix4::orthographic(-1, 1, -1, 1, 0, 1); viewMatrix = Matrix4::identity(); modelMatrix = Matrix4::identity(); set_viewport(); clear_buffer(); cellGcmSetDepthTestEnable(CELL_GCM_FALSE); //cellGcmSetDepthFunc(CELL_GCM_LESS); currentVert->UpdateShaderMatrices(modelMatrix, viewMatrix, aProjMatrix); SetTextureSampler(currentFrag->GetParameter("texture"), initMesh->GetDefaultTexture()); initMesh->Draw(*basicVert, *basicFrag); swap_buffers(); }
rtems_device_driver frame_buffer_control( rtems_device_major_number major, rtems_device_minor_number minor, void *arg ) { rtems_libio_ioctl_args_t *args = arg; switch (args->command) { case FBIOGET_FSCREENINFO: args->ioctl_return = get_fix_screen_info((struct fb_fix_screeninfo *)args->buffer); return RTEMS_SUCCESSFUL; case FBIOGET_VSCREENINFO: args->ioctl_return = get_var_screen_info((struct fb_var_screeninfo *)args->buffer); return RTEMS_SUCCESSFUL; case FBIOSWAPBUFFERS: swap_buffers(); args->ioctl_return = 0; return RTEMS_SUCCESSFUL; case FBIOSETBUFFERMODE: args->ioctl_return = 0; switch ((unsigned int)args->buffer) { case FB_SINGLE_BUFFERED: init_buffers(); fb_fix.smem_start = (volatile char *)frontbuffer; MM_WRITE(MM_VGA_BASEADDRESS, (unsigned int)frontbuffer); return RTEMS_SUCCESSFUL; case FB_TRIPLE_BUFFERED: fb_fix.smem_start = (volatile char *)backbuffer; return RTEMS_SUCCESSFUL; default: return RTEMS_UNSATISFIED; } case FBIOSETVIDEOMODE: set_video_mode((int)args->buffer); return RTEMS_SUCCESSFUL; default: args->ioctl_return = -1; return RTEMS_UNSATISFIED; } }
inline void ffast4_feature<V, T>::update(const image2d_V& in, const image2d_V& in_s2) { frame_cpt_++; swap_buffers(); dim3 dimblock(16, 16, 1); if (T == CPU) dimblock = dim3(in.ncols(), 2, 1); dim3 dimgrid = grid_dimension(in.domain(), dimblock); blurred_s1_ = in; blurred_s2_ = in_s2; //local_jet_static2_<0,0,1, 0,0,2, 6>::run(in, blurred_s1_, blurred_s2_, tmp_, pertinence2_); // if (!(frame_cpt_ % 5)) { if (target == unsigned(GPU)) { bindTexture2d(blurred_s1_, s1_tex); bindTexture2d(blurred_s2_, s2_tex); } pw_call<FFAST4_sig(target, V)>(flag<target>(), dimgrid, dimblock, color_blurred_, blurred_s1_, blurred_s2_, //*f_, pertinence_, grad_thresh_); // filter_pertinence<i_float1><<<dimgrid, dimblock>>> // (pertinence_, pertinence2_); // copy(pertinence2_, pertinence_); if (target == unsigned(GPU)) { cudaUnbindTexture(s1_tex); cudaUnbindTexture(s2_tex); check_cuda_error(); } } }
void rt_rtvi_displayimage(unsigned char * img, void * voidhandle) { rtvihandle * handle = (rtvihandle *) voidhandle; long x, y, width, height, xoffset, yoffset; unsigned char * row; PIXPTR * rtvirow; if (handle->xsize < SCREEN_WIDE) { width = handle->xsize; xoffset = (SCREEN_WIDE - handle->xsize) / 2; } else { width = SCREEN_WIDE; xoffset = 0; } if (handle->ysize < SCREEN_HI) { height = handle->ysize; yoffset = SCREEN_HI - 1 - ((SCREEN_HI - handle->ysize) / 2); } else { height = SCREEN_HI; yoffset = SCREEN_HI - 1; } for (x=0; x<SCREEN_WIDE; x++) { handle->scanline[0][x] = 0x00000000; handle->scanline[1][x] = 0x00000000; } for(y=0; y<height; y++) { row = &img[y * handle->xsize * 3]; rtvirow = handle->scanline[handle->flip]; for (x=0; x<width; x++) { rtvirow[x+xoffset] = row[x*3] | (row[x*3 + 1] << 8) | (row[x*3 + 2] << 16); } put_scanline(yoffset - y, handle->flip); handle->flip = 1 - handle->flip; } swap_buffers(); }
bool PIOS_Vsync_ISR() { static portBASE_TYPE xHigherPriorityTaskWoken; //PIOS_LED_Toggle(LED3); //if(gActiveLine > 200) xHigherPriorityTaskWoken = pdFALSE; m_osdLines = gActiveLine; { gActiveLine = 0; Vsync_update++; if(Vsync_update>=2) { swap_buffers(); Vsync_update=0; xHigherPriorityTaskWoken = xSemaphoreGiveFromISR(osdSemaphore, &xHigherPriorityTaskWoken); } } portEND_SWITCHING_ISR(xHigherPriorityTaskWoken); //portEND_SWITCHING_ISR(xHigherPriorityTaskWoken); return xHigherPriorityTaskWoken == pdTRUE; }
static int do_write_req(h2o_httpclient_t *_client, h2o_iovec_t chunk, int is_end_stream) { struct st_h2o_http1client_t *client = (struct st_h2o_http1client_t *)_client; client->_body_buf_is_done = is_end_stream; if (client->_body_buf == NULL) h2o_buffer_init(&client->_body_buf, &h2o_socket_buffer_prototype); if (chunk.len != 0) { if (h2o_buffer_append(&client->_body_buf, chunk.base, chunk.len) == 0) return -1; } if (client->sock->_cb.write != NULL) return 0; assert(client->_body_buf_in_flight == NULL || client->_body_buf_in_flight->size == 0); swap_buffers(&client->_body_buf, &client->_body_buf_in_flight); if (client->_body_buf_in_flight->size == 0) { /* return immediately if the chunk is empty */ on_req_body_done(client->sock, NULL); return 0; } h2o_iovec_t iov = h2o_iovec_init(client->_body_buf_in_flight->bytes, client->_body_buf_in_flight->size); if (client->_is_chunked) { h2o_iovec_t bufs[3]; size_t bufcnt = encode_chunk(client, bufs, iov); h2o_socket_write(client->sock, bufs, bufcnt, on_req_body_done); } else { h2o_socket_write(client->sock, &iov, 1, on_req_body_done); } return 0; }
static int SimpleExampleRun() { float angle; /* Normally, the first thing that you do is set up your communication and * then create at least one IceT context. This has already been done in * the calling function (i.e. icetTests_mpi.c). See the init_mpi in * test_mpi.h for an example. */ /* If we had set up the communication layer ourselves, we could have * gotten these parameters directly from it. Since we did not, this * provides an alternate way. */ icetGetIntegerv(ICET_RANK, &rank); icetGetIntegerv(ICET_NUM_PROCESSES, &num_proc); /* We should be able to set any color we want, but we should do it BEFORE * icetGLDrawFrame() is called, not in the callback drawing function. * There may also be limitations on the background color when performing * color blending. */ glClearColor(0.2f, 0.5f, 0.1f, 1.0f); /* Give IceT a function that will issue the OpenGL drawing commands. */ icetGLDrawCallback(draw); /* Give IceT the bounds of the polygons that will be drawn. Note that * we must take into account any transformation that happens within the * draw function (but IceT will take care of any transformation that * happens before icetGLDrawFrame). */ icetBoundingBoxd(-0.5+rank, 0.5+rank, -0.5, 0.5, -0.5, 0.5); /* Set up the tiled display. Normally, the display will be fixed for a * given installation, but since this is a demo, we give two specific * examples. */ if (num_proc < 4) { /* Here is an example of a "1 tile" case. This is functionally * identical to a traditional sort last algorithm. */ icetResetTiles(); icetAddTile(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0); } else { /* Here is an example of a 4x4 tile layout. The tiles are displayed * with the following ranks: * * +---+---+ * | 0 | 1 | * +---+---+ * | 2 | 3 | * +---+---+ * * Each tile is simply defined by grabing a viewport in an infinite * global display screen. The global viewport projection is * automatically set to the smallest region containing all tiles. * * This example also shows tiles abutted against each other. * Mullions and overlaps can be implemented by simply shifting tiles * on top of or away from each other. */ icetResetTiles(); icetAddTile(0, (IceTInt)SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT, 0); icetAddTile((IceTInt)SCREEN_WIDTH, (IceTInt)SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT, 1); icetAddTile(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 2); icetAddTile((IceTInt)SCREEN_WIDTH, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 3); } /* Tell IceT what strategy to use. The REDUCE strategy is an all-around * good performer. */ icetStrategy(ICET_STRATEGY_REDUCE); /* Set up the projection matrix as you normally would. */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-0.75, 0.75, -0.75, 0.75, -0.75, 0.75); /* Other normal OpenGL setup. */ glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); if (rank%8 != 0) { GLfloat color[4]; color[0] = (float)(rank%2); color[1] = (float)((rank/2)%2); color[2] = (float)((rank/4)%2); color[3] = 1.0f; glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color); } /* Here is an example of an animation loop. */ for (angle = 0; angle < 360; angle += 10) { /* We can set up a modelview matrix here and IceT will factor this * in determining the screen projection of the geometry. Note that * there is further transformation in the draw function that IceT * cannot take into account. That transformation is handled in the * application by deforming the bounds before giving them to * IceT. */ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRotated(angle, 0.0, 1.0, 0.0); glScaled(1.0f/num_proc, 1.0, 1.0); glTranslated(-(num_proc-1)/2.0, 0.0, 0.0); /* Instead of calling draw() directly, call it indirectly through * icetDrawFrame(). IceT will automatically handle image * compositing. */ icetGLDrawFrame(); /* For obvious reasons, IceT should be run in double-buffered frame * mode. After calling icetDrawFrame, the application should do a * synchronize (a barrier is often about as good as you can do) and * then a swap buffers. */ swap_buffers(); } return TEST_PASSED; }