int open_session() { SaErrorT rv; if (!g_thread_supported()) { g_thread_init(NULL); }; thread_wait = g_cond_new(); thread_mutex = g_mutex_new(); do_progress("Discover"); rv = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sessionid, NULL); if (rv != SA_OK) { printf("saHpiSessionOpen error %d\n", rv); return -1; } rv = saHpiDiscover(sessionid); if (rv != SA_OK) printf("saHpiDiscover rv = %d\n", rv); delete_progress(); printf("Initial discovery done\n"); Domain = init_resources(sessionid); if (Domain == (Domain_t *)NULL) { printf("init_resources error\n"); return -1; } printf("\tEnter a command or \"help\" for list of commands\n"); pthread_create(&ge_thread, NULL, get_event, NULL); return 0; }
static ret_code_t discovery(void) { SaErrorT ret; do_progress("Discover"); ret = saHpiDiscover(Domain->sessionId); if (SA_OK != ret) { printf("saHpiResourcesDiscover error = %s\n", oh_lookup_error(ret)); delete_progress(); return HPI_SHELL_CMD_ERROR; }; delete_progress(); return HPI_SHELL_OK; }
SaErrorT do_discover(Domain_t *domain) { SaErrorT rv; if (!domain->sessionId) { rv = get_sessionId(domain); if (rv != SA_OK) return(-1); }; if (domain->discovered) return(SA_OK); do_progress("Discover"); rv = saHpiDiscover(domain->sessionId); if (rv != SA_OK) { delete_progress(); printf("saHpiDiscover error %s\n", oh_lookup_error(rv)); return rv; }; delete_progress(); domain->discovered = 1; printf("Discovery done\n"); return(SA_OK); }
gint drag_received (GtkWidget* widget, GdkDragContext* drag_context, gint x, gint y, GtkSelectionData* data, guint info, guint time, gpointer user_data) { // this receives drops for the whole window. if(!data || data->length < 0){ perr("no data!\n"); return -1; } dbg(1, "%s", data->data); if(g_str_has_prefix((char*)data->data, "colour:")){ char* colour_string = (char*)data->data + 7; unsigned colour_index = atoi(colour_string) ? atoi(colour_string) - 1 : 0; // which row are we on? GtkTreePath* path; GtkTreeIter iter; gint tx, treeview_top; gdk_window_get_position(app->libraryview->widget->window, &tx, &treeview_top); dbg(2, "treeview_top=%i", y); #ifdef HAVE_GTK_2_12 gint bx, by; gtk_tree_view_convert_widget_to_bin_window_coords(GTK_TREE_VIEW(app->libraryview->widget), x, y - treeview_top, &bx, &by); dbg(2, "coords: %dx%d => %dx%d", x, y, bx, by); #else gint by = y - treeview_top - 20; #endif #ifdef USE_GDL GdkWindow* top_window = gdk_window_get_toplevel(gtk_widget_get_toplevel(app->libraryview->widget)->window); GdkWindow* window = app->libraryview->widget->window; while((window = gdk_window_get_parent(window)) != top_window){ gint x0, y0; gdk_window_get_position(window, &x0, &y0); by -= y0; } #endif if(gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(app->libraryview->widget), x, by, &path, NULL, NULL, NULL)){ gtk_tree_model_get_iter(GTK_TREE_MODEL(samplecat.store), &iter, path); gchar* path_str = gtk_tree_model_get_string_from_iter(GTK_TREE_MODEL(samplecat.store), &iter); dbg(2, "path=%s y=%i final_y=%i", path_str, y, y - treeview_top); listview_item_set_colour(path, colour_index); gtk_tree_path_free(path); } else dbg(0, "path not found."); return FALSE; } if(info == GPOINTER_TO_INT(GDK_SELECTION_TYPE_STRING)) printf(" type=string.\n"); if(info == GPOINTER_TO_INT(TARGET_URI_LIST)){ dbg(1, "type=uri_list. len=%i", data->length); GList* list = uri_list_to_glist((char*)data->data); if(g_list_length(list) < 1) pwarn("drag drop: uri list parsing found no uri's.\n"); int i = 0; ScanResults result = {0,}; GList* l = list; #ifdef __APPLE__ gdk_threads_enter(); #endif for(;l;l=l->next){ char* u = l->data; gchar* method_string; vfs_get_method_string(u, &method_string); dbg(2, "%i: %s method=%s", i, u, method_string); if(!strcmp(method_string, "file")){ //we could probably better use g_filename_from_uri() here //http://10.0.0.151/man/glib-2.0/glib-Character-Set-Conversion.html#g-filename-from-uri //-or perhaps get_local_path() from rox/src/support.c char* uri_unescaped = vfs_unescape_string(u + strlen(method_string) + 1, NULL); char* uri = (strstr(uri_unescaped, "///") == uri_unescaped) ? uri_unescaped + 2 : uri_unescaped; if(do_progress(0,0)) break; if(is_dir(uri)) application_add_dir(uri, &result); else application_add_file(uri, &result); g_free(uri_unescaped); } else pwarn("drag drop: unknown format: '%s'. Ignoring.\n", u); i++; } hide_progress(); #ifdef __APPLE__ gdk_threads_leave(); #endif statusbar_print(1, "import complete. %i files added", result.n_added); uri_list_free(list); } return FALSE; }
static void do_effects (int type) { float hue1, hue2, hue3, hue4; GLrgba color; float fade; int radius; int x, y; int i; int bloom_radius; int bloom_step; fade = WorldFade (); bloom_radius = 15; bloom_step = bloom_radius / 3; if (!TextureReady ()) return; //Now change projection modes so we can render full-screen effects glMatrixMode (GL_PROJECTION); glPushMatrix (); glLoadIdentity (); glOrtho (0, render_width, render_height, 0, 0.1f, 2048); glMatrixMode (GL_MODELVIEW); glPushMatrix (); glLoadIdentity(); glTranslatef(0, 0, -1.0f); glDisable (GL_CULL_FACE); glDisable (GL_FOG); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); //Render full-screen effects glBlendFunc (GL_ONE, GL_ONE); glEnable (GL_TEXTURE_2D); glDisable(GL_DEPTH_TEST); glDepthMask (false); glBindTexture(GL_TEXTURE_2D, TextureId (TEXTURE_BLOOM)); switch (type) { case EFFECT_DEBUG: glBindTexture(GL_TEXTURE_2D, TextureId (TEXTURE_LOGOS)); glDisable (GL_BLEND); glBegin (GL_QUADS); glColor3f (1, 1, 1); glTexCoord2f (0, 0); glVertex2i (0, render_height / 4); glTexCoord2f (0, 1); glVertex2i (0, 0); glTexCoord2f (1, 1); glVertex2i (render_width / 4, 0); glTexCoord2f (1, 0); glVertex2i (render_width / 4, render_height / 4); glTexCoord2f (0, 0); glVertex2i (0, 512); glTexCoord2f (0, 1); glVertex2i (0, 0); glTexCoord2f (1, 1); glVertex2i (512, 0); glTexCoord2f (1, 0); glVertex2i (512, 512); glEnd (); break; case EFFECT_BLOOM_RADIAL: //Psychedelic bloom glEnable (GL_BLEND); glBegin (GL_QUADS); color = WorldBloomColor () * BLOOM_SCALING * 2; glColor3fv (&color.red); for (i = 0; i <= 100; i+=10) { glTexCoord2f (0, 0); glVertex2i (-i, i + render_height); glTexCoord2f (0, 1); glVertex2i (-i, -i); glTexCoord2f (1, 1); glVertex2i (i + render_width, -i); glTexCoord2f (1, 0); glVertex2i (i + render_width, i + render_height); } glEnd (); break; case EFFECT_COLOR_CYCLE: //Oooh. Pretty colors. Tint the scene according to screenspace. hue1 = (float)(GetTickCount () % COLOR_CYCLE_TIME) / COLOR_CYCLE_TIME; hue2 = (float)((GetTickCount () + COLOR_CYCLE) % COLOR_CYCLE_TIME) / COLOR_CYCLE_TIME; hue3 = (float)((GetTickCount () + COLOR_CYCLE * 2) % COLOR_CYCLE_TIME) / COLOR_CYCLE_TIME; hue4 = (float)((GetTickCount () + COLOR_CYCLE * 3) % COLOR_CYCLE_TIME) / COLOR_CYCLE_TIME; glBindTexture(GL_TEXTURE_2D, 0); glEnable (GL_BLEND); glBlendFunc (GL_ONE, GL_ONE); glBlendFunc (GL_DST_COLOR, GL_SRC_COLOR); glBegin (GL_QUADS); color = glRgbaFromHsl (hue1, 1.0f, 0.6f); glColor3fv (&color.red); glTexCoord2f (0, 0); glVertex2i (0, render_height); color = glRgbaFromHsl (hue2, 1.0f, 0.6f); glColor3fv (&color.red); glTexCoord2f (0, 1); glVertex2i (0, 0); color = glRgbaFromHsl (hue3, 1.0f, 0.6f); glColor3fv (&color.red); glTexCoord2f (1, 1); glVertex2i (render_width, 0); color = glRgbaFromHsl (hue4, 1.0f, 0.6f); glColor3fv (&color.red); glTexCoord2f (1, 0); glVertex2i (render_width, render_height); glEnd (); break; case EFFECT_BLOOM: //Simple bloom effect glBegin (GL_QUADS); color = WorldBloomColor () * BLOOM_SCALING; glColor3fv (&color.red); for (x = -bloom_radius; x <= bloom_radius; x += bloom_step) { for (y = -bloom_radius; y <= bloom_radius; y += bloom_step) { if (abs (x) == abs (y) && x) continue; glTexCoord2f (0, 0); glVertex2i (x, y + render_height); glTexCoord2f (0, 1); glVertex2i (x, y); glTexCoord2f (1, 1); glVertex2i (x + render_width, y); glTexCoord2f (1, 0); glVertex2i (x + render_width, y + render_height); } } glEnd (); break; case EFFECT_DEBUG_OVERBLOOM: //This will punish that uppity GPU. Good for testing low frame rate behavior. glBegin (GL_QUADS); color = WorldBloomColor () * 0.01f; glColor3fv (&color.red); for (x = -50; x <= 50; x+=5) { for (y = -50; y <= 50; y+=5) { glTexCoord2f (0, 0); glVertex2i (x, y + render_height); glTexCoord2f (0, 1); glVertex2i (x, y); glTexCoord2f (1, 1); glVertex2i (x + render_width, y); glTexCoord2f (1, 0); glVertex2i (x + render_width, y + render_height); } } glEnd (); break; } //Do the fade to / from darkness used to hide scene transitions if (LOADING_SCREEN) { if (fade > 0.0f) { glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable (GL_BLEND); glDisable (GL_TEXTURE_2D); glColor4f (0, 0, 0, fade); glBegin (GL_QUADS); glVertex2i (0, 0); glVertex2i (0, render_height); glVertex2i (render_width, render_height); glVertex2i (render_width, 0); glEnd (); } if (TextureReady () && !EntityReady () && fade != 0.0f) { radius = render_width / 16; do_progress ((float)render_width / 2, (float)render_height / 2, (float)radius, fade, EntityProgress ()); RenderPrint (render_width / 2 - LOGO_PIXELS, render_height / 2 + LOGO_PIXELS, 0, glRgba (0.5f), "%1.2f%%", EntityProgress () * 100.0f); RenderPrint (1, "%s v%d.%d.%03d", APP_TITLE, VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION); } } glPopMatrix (); glMatrixMode (GL_PROJECTION); glPopMatrix (); glMatrixMode (GL_MODELVIEW); glEnable(GL_DEPTH_TEST); }