void icetResizeBuffer(int size) { /* Add some padding in case the user's data does not lie on byte boundries. */ size += 32*sizeof(IceTInt64); if (icet_current_context->buffer_size < size) { free(icet_current_context->buffer); icet_current_context->buffer = malloc(size); if (icet_current_context->buffer == NULL) { icetRaiseError("Could not allocate more buffer space", ICET_OUT_OF_MEMORY); /* Try to back out of change. */ icet_current_context->buffer = malloc(icet_current_context->buffer_size); if (icet_current_context->buffer == NULL) { icetRaiseError("Could not back out of memory change", ICET_OUT_OF_MEMORY); icet_current_context->buffer_size = 0; } } else { icet_current_context->buffer_size = size; } } icet_current_context->buffer_offset = 0; /* The color and depth buffers rely on this memory pool, so we have probably just invalidated them. */ icetStateSetBoolean(ICET_COLOR_BUFFER_VALID, 0); icetStateSetBoolean(ICET_DEPTH_BUFFER_VALID, 0); }
void icetStateSetDefaults(void) { GLint *int_array; int i; icetDiagnostics(ICET_DIAG_ALL_NODES | ICET_DIAG_WARNINGS); icetStateSetInteger(ICET_RANK, ICET_COMM_RANK()); icetStateSetInteger(ICET_NUM_PROCESSES, ICET_COMM_SIZE()); icetStateSetInteger(ICET_ABSOLUTE_FAR_DEPTH, 1); /*icetStateSetInteger(ICET_ABSOLUTE_FAR_DEPTH, 0xFFFFFFFF);*/ icetStateSetFloatv(ICET_BACKGROUND_COLOR, 4, black); icetStateSetInteger(ICET_BACKGROUND_COLOR_WORD, 0); icetResetTiles(); icetStateSetIntegerv(ICET_DISPLAY_NODES, 0, NULL); icetStateSetDoublev(ICET_GEOMETRY_BOUNDS, 0, NULL); icetStateSetInteger(ICET_NUM_BOUNDING_VERTS, 0); icetStateSetPointer(ICET_STRATEGY_COMPOSE, NULL); icetInputOutputBuffers(ICET_COLOR_BUFFER_BIT | ICET_DEPTH_BUFFER_BIT, ICET_COLOR_BUFFER_BIT); int_array = malloc(ICET_COMM_SIZE() * sizeof(GLint)); for (i = 0; i < ICET_COMM_SIZE(); i++) { int_array[i] = i; } icetStateSetIntegerv(ICET_COMPOSITE_ORDER, ICET_COMM_SIZE(), int_array); icetStateSetIntegerv(ICET_PROCESS_ORDERS, ICET_COMM_SIZE(), int_array); free(int_array); icetStateSetInteger(ICET_DATA_REPLICATION_GROUP, ICET_COMM_RANK()); icetStateSetInteger(ICET_DATA_REPLICATION_GROUP_SIZE, 1); icetStateSetPointer(ICET_DRAW_FUNCTION, NULL); icetStateSetInteger(ICET_READ_BUFFER, GL_BACK); #ifdef _WIN32 icetStateSetInteger(ICET_COLOR_FORMAT, GL_BGRA_EXT); #else icetStateSetInteger(ICET_COLOR_FORMAT, GL_RGBA); #endif icetStateSetInteger(ICET_FRAME_COUNT, 0); icetEnable(ICET_FLOATING_VIEWPORT); icetDisable(ICET_ORDERED_COMPOSITE); icetDisable(ICET_CORRECT_COLORED_BACKGROUND); icetEnable(ICET_DISPLAY); icetDisable(ICET_DISPLAY_COLORED_BACKGROUND); icetDisable(ICET_DISPLAY_INFLATE); icetEnable(ICET_DISPLAY_INFLATE_WITH_HARDWARE); icetStateSetBoolean(ICET_IS_DRAWING_FRAME, 0); icetStateSetPointer(ICET_COLOR_BUFFER, NULL); icetStateSetPointer(ICET_DEPTH_BUFFER, NULL); icetStateSetBoolean(ICET_COLOR_BUFFER_VALID, 0); icetStateSetBoolean(ICET_DEPTH_BUFFER_VALID, 0); icetStateResetTiming(); }
static IceTImage drawInvokeStrategy(void) { IceTImage image; IceTVoid *value; IceTEnum strategy; IceTInt display_tile; IceTInt valid_tile; icetGetPointerv(ICET_DRAW_FUNCTION, &value); if (value == NULL) { icetRaiseError("Drawing function not set. Call icetDrawCallback.", ICET_INVALID_OPERATION); return icetImageNull(); } icetRaiseDebug("Calling strategy"); icetStateSetBoolean(ICET_IS_DRAWING_FRAME, 1); icetGetEnumv(ICET_STRATEGY, &strategy); image = icetInvokeStrategy(strategy); icetStateSetBoolean(ICET_IS_DRAWING_FRAME, 0); /* Ensure that the returned image is the expected size. */ icetGetIntegerv(ICET_VALID_PIXELS_TILE, &valid_tile); icetGetIntegerv(ICET_TILE_DISPLAYED, &display_tile); if ((valid_tile != display_tile) && icetIsEnabled(ICET_COLLECT_IMAGES)) { icetRaiseDebug2("Display tile: %d, valid tile: %d", display_tile, valid_tile); icetRaiseError("Got unexpected tile from strategy.", ICET_SANITY_CHECK_FAIL); } if (valid_tile >= 0) { const IceTInt *valid_tile_viewport = icetUnsafeStateGetInteger(ICET_TILE_VIEWPORTS) + 4*valid_tile; if ( (valid_tile_viewport[2] != icetImageGetWidth(image)) || (valid_tile_viewport[3] != icetImageGetHeight(image)) ) { IceTInt valid_offset; IceTInt valid_num; icetRaiseDebug1("Tile returned from strategy: %d\n", valid_tile); icetRaiseDebug4("Expected size: %d %d. Returned size: %d %d", valid_tile_viewport[2], valid_tile_viewport[3], (int)icetImageGetWidth(image), (int)icetImageGetHeight(image)); icetGetIntegerv(ICET_VALID_PIXELS_OFFSET, &valid_offset); icetGetIntegerv(ICET_VALID_PIXELS_NUM, &valid_num); icetRaiseDebug2("Reported pixel offset: %d. Reported pixel count: %d", valid_offset, valid_num); icetRaiseError("Got unexpected image size from strategy.", ICET_SANITY_CHECK_FAIL); } } icetStateCheckMemory(); return image; }
void icetDisable(IceTEnum pname) { if ((pname < ICET_STATE_ENABLE_START) || (pname >= ICET_STATE_ENABLE_END)) { icetRaiseError("Bad value to icetDisable", ICET_INVALID_VALUE); return; } icetStateSetBoolean(pname, ICET_FALSE); }
void icetStrategy(IceTEnum strategy) { if (icetStrategyValid(strategy)) { icetStateSetInteger(ICET_STRATEGY, strategy); icetStateSetBoolean(ICET_STRATEGY_SUPPORTS_ORDERING, icetStrategySupportsOrdering(strategy)); } else { icetRaiseError("Invalid strategy.", ICET_INVALID_ENUM); } }
static void drawUseBackgroundColor(const IceTFloat *background_color) { IceTUInt background_color_word; IceTBoolean use_color_blending = (IceTBoolean)( *(icetUnsafeStateGetInteger(ICET_COMPOSITE_MODE)) == ICET_COMPOSITE_MODE_BLEND); ((IceTUByte *)&background_color_word)[0] = (IceTUByte)(255*background_color[0]); ((IceTUByte *)&background_color_word)[1] = (IceTUByte)(255*background_color[1]); ((IceTUByte *)&background_color_word)[2] = (IceTUByte)(255*background_color[2]); ((IceTUByte *)&background_color_word)[3] = (IceTUByte)(255*background_color[3]); icetStateSetFloatv(ICET_TRUE_BACKGROUND_COLOR, 4, background_color); icetStateSetInteger(ICET_TRUE_BACKGROUND_COLOR_WORD, background_color_word); if (use_color_blending) { IceTInt display_tile; /* We need to correct the background color by zeroing it out at * blending it back at the end. */ icetStateSetFloatv(ICET_BACKGROUND_COLOR, 4, black); icetStateSetInteger(ICET_BACKGROUND_COLOR_WORD, 0); icetGetIntegerv(ICET_TILE_DISPLAYED, &display_tile); if ( (background_color_word != 0) && icetIsEnabled(ICET_CORRECT_COLORED_BACKGROUND) ) { icetStateSetBoolean(ICET_NEED_BACKGROUND_CORRECTION, ICET_TRUE); } else { icetStateSetBoolean(ICET_NEED_BACKGROUND_CORRECTION, ICET_FALSE); } } else { icetStateSetFloatv(ICET_BACKGROUND_COLOR, 4, background_color); icetStateSetInteger(ICET_BACKGROUND_COLOR_WORD, background_color_word); icetStateSetBoolean(ICET_NEED_BACKGROUND_CORRECTION, ICET_FALSE); } }
void icetGLInitialize(void) { if (icetGLIsInitialized()) { icetRaiseWarning("icetGLInitialize called multiple times.", ICET_INVALID_OPERATION); } icetStateSetBoolean(ICET_GL_INITIALIZED, ICET_TRUE); icetGLSetReadBuffer(GL_BACK); icetStateSetPointer(ICET_GL_DRAW_FUNCTION, NULL); icetStateSetInteger(ICET_GL_INFLATE_TEXTURE, 0); icetEnable(ICET_GL_DISPLAY); icetDisable(ICET_GL_DISPLAY_COLORED_BACKGROUND); icetDisable(ICET_GL_DISPLAY_INFLATE); icetEnable(ICET_GL_DISPLAY_INFLATE_WITH_HARDWARE); icetStateSetPointer(ICET_RENDER_LAYER_DESTRUCTOR, gl_destroy); }
void icetStateSetDefaults(void) { IceTInt *int_array; int i; int comm_size, comm_rank; icetDiagnostics(ICET_DIAG_ALL_NODES | ICET_DIAG_WARNINGS); comm_size = icetCommSize(); comm_rank = icetCommRank(); icetStateSetInteger(ICET_RANK, comm_rank); icetStateSetInteger(ICET_NUM_PROCESSES, comm_size); /* icetStateSetInteger(ICET_ABSOLUTE_FAR_DEPTH, 1); */ /*icetStateSetInteger(ICET_ABSOLUTE_FAR_DEPTH, 0xFFFFFFFF);*/ icetStateSetFloatv(ICET_BACKGROUND_COLOR, 4, black); icetStateSetInteger(ICET_BACKGROUND_COLOR_WORD, 0); icetStateSetInteger(ICET_COLOR_FORMAT, ICET_IMAGE_COLOR_RGBA_UBYTE); icetStateSetInteger(ICET_DEPTH_FORMAT, ICET_IMAGE_DEPTH_FLOAT); icetResetTiles(); icetStateSetIntegerv(ICET_DISPLAY_NODES, 0, NULL); icetStateSetDoublev(ICET_GEOMETRY_BOUNDS, 0, NULL); icetStateSetInteger(ICET_NUM_BOUNDING_VERTS, 0); icetStateSetInteger(ICET_STRATEGY, ICET_STRATEGY_UNDEFINED); icetSingleImageStrategy(ICET_SINGLE_IMAGE_STRATEGY_AUTOMATIC); icetCompositeMode(ICET_COMPOSITE_MODE_Z_BUFFER); int_array = icetStateAllocateInteger(ICET_COMPOSITE_ORDER, comm_size); for (i = 0; i < comm_size; i++) { int_array[i] = i; } int_array = icetStateAllocateInteger(ICET_PROCESS_ORDERS, comm_size); for (i = 0; i < comm_size; i++) { int_array[i] = i; } icetStateSetInteger(ICET_DATA_REPLICATION_GROUP, comm_rank); icetStateSetInteger(ICET_DATA_REPLICATION_GROUP_SIZE, 1); icetStateSetInteger(ICET_FRAME_COUNT, 0); if (getenv("ICET_MAGIC_K") != NULL) { IceTInt magic_k = atoi(getenv("ICET_MAGIC_K")); if (magic_k > 1) { icetStateSetInteger(ICET_MAGIC_K, magic_k); } else { icetRaiseError("Environment varible ICET_MAGIC_K must be set" " to an integer greater than 1.", ICET_INVALID_VALUE); icetStateSetInteger(ICET_MAGIC_K, ICET_MAGIC_K_DEFAULT); } } else { icetStateSetInteger(ICET_MAGIC_K, ICET_MAGIC_K_DEFAULT); } if (getenv("ICET_MAX_IMAGE_SPLIT") != NULL) { IceTInt max_image_split = atoi(getenv("ICET_MAX_IMAGE_SPLIT")); if (max_image_split > 0) { icetStateSetInteger(ICET_MAX_IMAGE_SPLIT, max_image_split); } else { icetRaiseError("Environment variable ICET_MAX_IMAGE_SPLIT must be" " set to an integer greater than 0.", ICET_INVALID_VALUE); icetStateSetInteger(ICET_MAX_IMAGE_SPLIT, ICET_MAX_IMAGE_SPLIT_DEFAULT); } } else { icetStateSetInteger(ICET_MAX_IMAGE_SPLIT, ICET_MAX_IMAGE_SPLIT_DEFAULT); } icetStateSetPointer(ICET_DRAW_FUNCTION, NULL); icetStateSetPointer(ICET_RENDER_LAYER_DESTRUCTOR, NULL); icetEnable(ICET_FLOATING_VIEWPORT); icetDisable(ICET_ORDERED_COMPOSITE); icetDisable(ICET_CORRECT_COLORED_BACKGROUND); icetEnable(ICET_COMPOSITE_ONE_BUFFER); icetEnable(ICET_INTERLACE_IMAGES); icetEnable(ICET_COLLECT_IMAGES); icetDisable(ICET_RENDER_EMPTY_IMAGES); icetStateSetBoolean(ICET_IS_DRAWING_FRAME, 0); icetStateSetBoolean(ICET_RENDER_BUFFER_SIZE, 0); icetStateSetInteger(ICET_VALID_PIXELS_TILE, -1); icetStateSetInteger(ICET_VALID_PIXELS_OFFSET, 0); icetStateSetInteger(ICET_VALID_PIXELS_NUM, 0); icetStateResetTiming(); }