Changes between Version 36 and Version 37 of GraphicsApi
- Timestamp:
- Aug 7, 2014, 10:12:14 AM (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GraphicsApi
v36 v37 10 10 == Graphics apps == 11 11 12 The most general way of providing graphics involves 13 using a 'graphics app' program (separate from your main application). 12 Graphics are generated by a 'graphics app' program (separate from the main application). 14 13 This graphics app must have the properties that: 15 14 … … 98 97 This can be done efficiently using shared memory. 99 98 The BOINC library supplies the following functions to facilitate this: 99 100 100 {{{ 101 101 void* boinc_graphics_make_shmem(char* appname, int size); 102 }}} 103 Called from the main app. 104 Creates a shared memory segment of the given size. 105 'appname' should be the name of this application (used to ensure uniqueness of the shared-memory segment name). 106 107 {{{ 102 108 void* boinc_graphics_get_shmem(char* appname); 103 109 }}} 104 `boinc_graphics_make_shmem()` (called from the main app) creates a shared memory segment of the given size. 105 'appname' should be the name of this application (used to ensure uniqueness of the shared-memory segment name). 106 `boinc_graphics_get_shmem()` (called from the graphics app) attaches to an existing segment. 110 Called from the graphics app. 111 Attaches to an existing segment. 107 112 It must be called AFTER boinc_parse_init_data_file(). 108 113 109 The contents of the shared memory segment are up to you. 114 The contents of the shared memory segment are application-dependent; 115 typically it contains numeric information describing the state of the computation. 116 110 117 You may want to include the following items: 111 118 {{{ … … 115 122 double cpu_time; 116 123 BOINC_STATUS status; 124 int countdown; 117 125 }; 118 126 }}} 119 127 120 Th is structureshould be updated by the main app once per second,128 These items should be updated by the main app once per second, 121 129 using [BasicApi#timer boinc_set_timer_handler()]. 122 130 The items are: 123 update_time:: The current time (dtime()). 124 The graphics app should exit if the current time exceeds this by 5 seconds or so. 125 fraction_done:: The last fraction done reported by the main app. 126 cpu_time:: The current CPU time. 127 status:: The BOINC status. If the 'suspended' flag is set, 128 the graphics app should stop changing its display, 129 and instead display an "application suspended" message. 131 update_time:: 132 The current time (dtime()). 133 The graphics app should exit if the current time exceeds this by 5 seconds or so, 134 so that it exits if the main app exits. 135 fraction_done:: 136 The last fraction done reported by the main app. 137 cpu_time:: 138 The current CPU time, as returned by '''boinc_worker_thread_cpu_time()'''. 139 status:: 140 The BOINC status, as returned by '''boinc_get_status()'''. 141 If the 'suspended' flag is set, 142 the graphics app should stop changing its display, 143 and instead show an "application suspended" message. 144 countdown:: 145 See below. 130 146 131 147 Keep in mind that multiple instances of the graphics app may run simultaneously; … … 134 150 use a semaphore to synchronize access so that the graphics app 135 151 doesn't see an inconsistent state. 152 153 === Efficiency === 154 155 Updating the shared memory structure uses CPU time, 156 and it's desirable to avoid this overhead if no graphics app is running. 157 158 One way to do this is to include a '''countdown''' field in the shared memory structure, as above. 159 * The graphics sets this to 5 (say) in its '''app_graphics_render()''' function. 160 * The main app decrements this (if positive) once per second. 161 * The main app updates the application-specific data in shared memory 162 only when '''countdown''' is nonzero. 163 164 See [ExampleApps the example application] for an example. 136 165 137 166 === Creating an icon for your applications ===