void scolarships::students::List::Map( void (*CallbackFunc) (Student*) ) { for(int i = 0; i < Size(); i++) { CallbackFunc(studentList[i]); } }
int DDE::EnumFileAssocations(dictionary* ini, bool isRegister, int (*CallbackFunc)(DDEInfo&)) { // For the moment just register all char key[MAX_PATH]; int res = 0; for(int i = 1;; i++) { DDEInfo info; info.ini = ini; sprintf(key, "FileAssociations:file.%d.extension", i); info.extension = iniparser_getstr(ini, key); if(info.extension == NULL) break; Log::Info(isRegister ? "Registering %s" : "Unregistering %s", info.extension); sprintf(key, "FileAssociations:file.%d.name", i); info.name = iniparser_getstr(ini, key); if(info.name == NULL) { Log::Error("Name not specified for extension: %s", info.extension); return 1; } sprintf(key, "FileAssociations:file.%d.description", i); info.description = iniparser_getstr(ini, key); if(info.description == NULL) { Log::Warning("Description not specified for extension: %s", info.extension); } if(res = CallbackFunc(info)) return res; } return res; }
void RayTraceDataGenerator::GenerateRaytraceResult(int width, int height,float scale, XMFLOAT4 loc, int neardistance, int maxdepth, XMFLOAT4 n, XMFLOAT4 up, void(*CallbackFunc)(int x, int y, const int& TexType, const XMFLOAT4& loc, const XMFLOAT4& n,const float& depth, void* arg), void* arg) { XMVECTOR v_ori = XMLoadFloat4(&loc); XMVECTOR v_center=XMLoadFloat4(&loc); XMVECTOR v_n = XMLoadFloat4(&n); XMVECTOR v_up = XMVector3Normalize(XMLoadFloat4(&up)); v_center = XMVectorAdd(v_center, XMVectorScale(v_n, neardistance)); XMVECTOR v_dir_x = XMVector3Cross(v_n, v_up); XMVECTOR v_dir_y = XMVector3Cross(v_n, v_dir_x); XMVECTOR v_current = XMVectorAdd(v_center, XMVectorScale(v_dir_x, -scale*width*0.5)); XMVECTOR v_ret_n; XMVECTOR v_ret_loc; //XMFLOAT4 v_unpacked; XMFLOAT4 v_ret_unpack_n; XMFLOAT4 v_ret_unpack_loc; XMVECTOR v_corner1; XMVECTOR v_corner2; bool result; float f_ret_depth; v_current = XMVectorAdd(v_current, XMVectorScale(v_dir_y, -scale*height*0.5)); v_corner1 = v_current; v_corner2 = XMVectorAdd(v_current, XMVectorScale(v_dir_y, +scale*height*1.0)); v_corner2 = XMVectorAdd(v_corner2, XMVectorScale(v_dir_x, +scale*width*1.0)); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) {//XMVector3Normalize(XMVectorSubtract(v_current, v_ori)) result = CalcIntersect(v_current, v_n, &v_ret_n, &v_ret_loc, &f_ret_depth); if (result) { XMStoreFloat4(&v_ret_unpack_loc,v_ret_loc); XMStoreFloat4(&v_ret_unpack_n, v_ret_n); CallbackFunc(i, j, GetLocInfo((int)v_ret_unpack_loc.x, (int)v_ret_unpack_loc.y, (int)v_ret_unpack_loc.z), v_ret_unpack_loc, v_ret_unpack_n, f_ret_depth, arg); } else { v_ret_unpack_n.x = v_ret_unpack_n.y = v_ret_unpack_n.z = -1; v_ret_unpack_loc.x = v_ret_unpack_loc.y = v_ret_unpack_loc.z = -1; f_ret_depth = -1; CallbackFunc(i, j, -1, v_ret_unpack_loc, v_ret_unpack_n, f_ret_depth, arg); } v_current = XMVectorAdd(v_current, XMVectorScale(v_dir_y, scale)); } v_current = XMVectorAdd(v_current, XMVectorScale(v_dir_x, scale)); } }