void XGraphicsOpenGL::FillRect( float x, float y, float w, float h, XCOLOR collt, XCOLOR colrt, XCOLOR collb, XCOLOR colrb ) { if( w == 0 || h == 0 ) return; if( w < 0 ) { x -= w; // 좌측 좌표를 -w만큼 이동시켜주고 w = -w; // w는 부호 바꿈 } if( h < 0 ) { y -= h; h = -h; } if( x > GetScreenWidth() || y > GetScreenHeight() ) // w, h가 마이너스가 올수도 있기땜에 이렇게 함 return; if( x + w < 0 || y + h < 0 ) return; // if( x > GetScreenWidth() || y > GetScreenHeight() ) // return; // if( w < 0 || h < 0 ) // return; // GLfloat r, g, b, a; // r = XCOLOR_RGB_R(color) / 255.0f; // g = XCOLOR_RGB_G(color) / 255.0f; // b = XCOLOR_RGB_B(color) / 255.0f; // a = XCOLOR_RGB_A(color) / 255.0f; // if( a != 255 ) glEnable(GL_BLEND); // 이거 자주불러주면 부하걸릴거 같다. 외부에서 블럭단위로 셋하게 하자. // width-1이 맞나? 안하는게 맞나? GLfloat pos[8] = { 0, h, w, h, 0, 0, w, 0 }; GLfloat col[16] = { _R(collb), _G(collb),_B(collb),_A(collb), // 좌하 _R(colrb), _G(colrb),_B(colrb),_A(colrb), // 우하 _R(collt), _G(collt),_B(collt),_A(collt), // 좌상 _R(colrt), _G(colrt),_B(colrt),_A(colrt) }; // 우상 glPushMatrix(); glLoadIdentity(); glTranslatef(x, y, 0); glScalef(1.0f, 1.0f, 1.0f); // glLoadIdentity(); glDisable( GL_TEXTURE_2D ); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); // 이건 안해줘도 되네. glVertexPointer(2, GL_FLOAT, 0, pos); glEnableClientState(GL_VERTEX_ARRAY); glColorPointer(4, GL_FLOAT, 0, col); glEnableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDisableClientState(GL_COLOR_ARRAY); glEnable( GL_TEXTURE_2D ); glPopMatrix(); // if( a != 255 ) glDisable(GL_BLEND); }
CAMLprim value stub_gnttab_map_fresh( value xgh, value reference, value domid, value writable ) { CAMLparam4(xgh, reference, domid, writable); CAMLlocal2(pair, contents); void *map = xc_gnttab_map_grant_ref(_G(xgh), Int_val(domid), Int_val(reference), Bool_val(writable)?PROT_READ | PROT_WRITE:PROT_READ); if(map==NULL) { caml_failwith("Failed to map grant ref"); } contents = caml_ba_alloc_dims(XC_GNTTAB_BIGARRAY, 1, map, 1 << XC_PAGE_SHIFT); pair = caml_alloc_tuple(2); Store_field(pair, 0, contents); /* grant_handle */ Store_field(pair, 1, contents); /* Io_page.t */ CAMLreturn(pair); }
CAMLprim value stub_gnttab_mapv_batched( value xgh, value array, value writable) { CAMLparam3(xgh, array, writable); CAMLlocal4(domid, reference, contents, pair); int count = Wosize_val(array) / 2; uint32_t domids[count]; uint32_t refs[count]; int i; for (i = 0; i < count; i++) { domids[i] = Int_val(Field(array, i * 2 + 0)); refs[i] = Int_val(Field(array, i * 2 + 1)); } void *map = xc_gnttab_map_grant_refs(_G(xgh), count, domids, refs, Bool_val(writable)?PROT_READ | PROT_WRITE : PROT_READ); if(map==NULL) { caml_failwith("Failed to map grant ref"); } contents = caml_ba_alloc_dims(XC_GNTTAB_BIGARRAY, 1, map, count << XC_PAGE_SHIFT); pair = caml_alloc_tuple(2); Store_field(pair, 0, contents); /* grant_handle */ Store_field(pair, 1, contents); /* Io_page.t */ CAMLreturn(pair); }
CAMLprim value stub_xc_gntshr_munmap(value xgh, value share) { CAMLparam2(xgh, share); CAMLlocal1(ml_map); #ifdef HAVE_GNTSHR ml_map = Field(share, 1); int size = Caml_ba_array_val(ml_map)->dim[0]; int pages = size >> XC_PAGE_SHIFT; int result = xc_gntshr_munmap(_G(xgh), Caml_ba_data_val(ml_map), pages); if(result != 0) failwith_xc(_G(xgh)); #else gntshr_missing(); #endif CAMLreturn(Val_unit); }
CAMLprim value stub_gnttab_interface_close(value xgh) { CAMLparam1(xgh); xc_gnttab_close(_G(xgh)); CAMLreturn(Val_unit); }
CAMLprim value stub_xc_gntshr_share_pages(value xgh, value domid, value count, value writeable) { CAMLparam4(xgh, domid, count, writeable); CAMLlocal4(result, ml_refs, ml_refs_cons, ml_map); #ifdef HAVE_GNTSHR void *map; uint32_t *refs; uint32_t c_domid; int c_count; int i; c_count = Int_val(count); c_domid = Int32_val(domid); result = caml_alloc(2, 0); refs = (uint32_t *) malloc(c_count * sizeof(uint32_t)); map = xc_gntshr_share_pages(_G(xgh), c_domid, c_count, refs, Bool_val(writeable)); if(NULL == map) { free(refs); failwith_xc(_G(xgh)); } // Construct the list of grant references. ml_refs = Val_emptylist; for(i = c_count - 1; i >= 0; i--) { ml_refs_cons = caml_alloc(2, 0); Store_field(ml_refs_cons, 0, caml_copy_int32(refs[i])); Store_field(ml_refs_cons, 1, ml_refs); ml_refs = ml_refs_cons; } ml_map = caml_ba_alloc_dims(XC_GNTTAB_BIGARRAY, 1, map, c_count << XC_PAGE_SHIFT); Store_field(result, 0, ml_refs); Store_field(result, 1, ml_map); free(refs); #else gntshr_missing(); #endif CAMLreturn(result); }
CAMLprim value stub_xc_gntshr_close(value xgh) { CAMLparam1(xgh); #ifdef HAVE_GNTSHR xc_gntshr_close(_G(xgh)); #else gntshr_missing(); #endif CAMLreturn(Val_unit); }
void CPDNRigid<T, D>::constructG() { _G = TMatrix::Zero(_M, _M); for (size_t i = 0; i < _M; i ++) { for (size_t j = 0; j < _M; j ++) { _G(i, j) = exp(-TVector(_model.row(i)-_model.row(j)).squaredNorm()/(2*_paras._beta*_paras._beta)); } } }
CAMLprim value stub_gnttab_unmap(value xgh, value array) { CAMLparam2(xgh, array); int size = Caml_ba_array_val(array)->dim[0]; int pages = size >> XC_PAGE_SHIFT; int result = xc_gnttab_munmap(_G(xgh), Caml_ba_data_val(array), pages); if(result!=0) { caml_failwith("Failed to unmap grant"); } CAMLreturn(Val_unit); }
CAMLprim value stub_gntshr_munmap_batched(value xgh, value share) { CAMLparam2(xgh, share); CAMLlocal1(ml_map); #ifdef HAVE_GNTSHR ml_map = Field(share, 1); int size = Bigarray_val(ml_map)->dim[0]; int pages = size >> XC_PAGE_SHIFT; #ifdef linux /* Bug in xen-4.4 libxc xc_linux_osdep implementation, work-around by using the kernel interface directly. */ int result = munmap(Data_bigarray_val(ml_map), size); #else int result = xc_gntshr_munmap(_G(xgh), Data_bigarray_val(ml_map), pages); #endif if(result != 0) failwith_xc(_G(xgh)); #else gntshr_missing(); #endif CAMLreturn(Val_unit); }
//Пусть эта штука будет рекурсивно себя вызывать и возвращать число итераций int layer(double eps,int n,double tau,double h,double *v,double *hat_v){ double err,gamma,*a,*c,*d,*b,*w,*pts[5]; int i; new_double(5,n,pts); a = pts[0]; c = pts[1]; d = pts[2]; b = pts[3]; w = pts[4]; _G(n,b,tau,h,v,hat_v); err = norm_max(n,b); if (err<eps) printf("Ошибка %e\neps %e\n",norm_max(n,b),eps); if (norm_max(n,b) < eps) { clean_all(5,pts); return 0; } for(i=n-6,a[n-5] = 1/tau;i>=0;i--) { a[i] = 1/tau; c[i] = hat_v[i+3]/(2*h); d[i] = -hat_v[i+2]/(2*h); } thomas(n-4,w+2,a,c,d,b); for (gamma=1.;gamma>AESH_MIN;gamma/=2.){ if (gamma<10*AESH_MIN) exit(-1); for (i=2;i<n-2;i++) hat_v[i] += gamma * w[i]; _G(n,b,tau,h,v,hat_v); printf("Ошибка %e\n",norm_max(n,b)); if (norm_max(n,b)<err) break; for (i=2;i<n-2;i++) hat_v[i] -= gamma * w[i]; } clean_all(5,pts); return 1 + layer(eps,n,tau,h,v,hat_v); }
bool isWhitePixel(int i, int j, char * image, int threshold) { /*unsigned int b = image[_B(i, j)]; unsigned int g = image[_G(i, j)]; unsigned int r = image[_R(i, j)];*/ unsigned char b = image[_B(i, j)]; unsigned char g = image[_G(i, j)]; unsigned char r = image[_R(i, j)]; unsigned int r_ = r; unsigned int g_ = g; unsigned int b_ = b; //return ((image[_B(i, j)] > threshold) && // (image[_G(i, j)] > threshold) && // (image[_R(i, j)] > threshold)); return ( (b > threshold) && (g > threshold) && (r > threshold) ); //return ( (*(image + _B(i, j)) > threshold) && // (*(image + _G(i, j)) > threshold) && // (*(image + _R(i, j)) > threshold) ); }
/***************************************************************************** 函 数 名: acl_rfc_get_rule 功能描述: 获取规则。起始规则号和当前套数均存放于全局变量中。 输入参数: 无 输出参数: cnt ---- 规则数 返 回 值: ERROR_SUCCESS ---- 未查到 else ---- 找到的规则的动作位置 ----------------------------------------------------------------------------- 最近一次修改记录: 修改作者: Fuzhiqing 修改目的: 当某轮取到的规则数为0时,表示规则已取尽,此时gs_current_num已表示表的套数,不应再自增。 修改日期: 2011年05月18日 *****************************************************************************/ s32 acl_rfc_get_rule (struct acl_rfc_data_k_and_u* data) { drv_acl_rule_t* l3_rule; u32* acl_rule_total_num; s32 i, j;/* i为内核规则位置,从0开始。j为某规则中入端口序号,从0开始。 */ struct acl_rfc_rule *rule_user = data->rule_arr; lsw_acl_rule_s** acl_rule = get_gs_acl_rule(DRV_ACL_ICAP); lsw_acl_user_action_s** acl_action = get_gs_acl_action(DRV_ACL_ICAP); u32 module_id, port_id; acl_pub_info_s _pub = {RFC_ACL_SLOT_ID, DRV_ACL_ICAP}, *pub = &_pub; acl_rule_total_num = get_gs_acl_rule_total_num(DRV_ACL_ICAP); for (i = gs_cur_rule_prio.rule, data->copy_number = 0; i < acl_rule_total_num[RFC_ACL_SLOT_ID]; i++) { if (0 == _G(pub).gs_acl_rule_bitmap[RFC_ACL_SLOT_ID][i/BIT_PER_BYTE]) /* 当前字节全0则全跳过,加快循环 */ { i = (i / BIT_PER_BYTE + 1) * BIT_PER_BYTE; continue; } /* 判断此条规则是否存在且生效。RFC ACL皆为三层ACL,不考虑类型切换 */ if (!RULE_BITMAP_IS_SET(pub, i) || ACL_TIME_NONE == acl_rule[RFC_ACL_SLOT_ID][i].in_chip) { continue; } for (j = gs_cur_rule_prio.port; j < DRV_IFINDEX_NUM_MAX; j++) { l3_rule = &acl_rule[RFC_ACL_SLOT_ID][i].rule; PRINTK_F(7, "i: %d, j: %d, cur_rule: %d/%d, copy_number: %d. port: 0x%04x.", i, j, gs_cur_rule_prio.rule, gs_cur_rule_prio.port, data->copy_number, l3_rule->in_ifindex_bitmap[j]); if (ACL_U32_BITMAP_TEST(l3_rule->rule_type, DRV_ACL_IN_PORTS) && U16_MAX != l3_rule->in_ifindex_bitmap[0]) { if (U16_MAX != l3_rule->in_ifindex_bitmap[j]) { /*拼出ifindex作为参数。入端口用驱动传的逻辑端口号 */ eth_common_get_modport_by_ifindex(GET_ETH_IFINDEX(l3_rule->in_ifindex_bitmap[j]), &module_id, &port_id); rule_user->in_port = port_id; } else { break;/* 该规则的所有端口都已遍历完,去遍历下一条规则 */ } } else { rule_user->in_port = PORT_ID_ALL; j = DRV_IFINDEX_NUM_MAX - 1; /* 最后一轮内循环 */ } if (ACL_U32_BITMAP_TEST(l3_rule->rule_type, DRV_ACL_SRC_IP)) { rule_user->sip_high = IP_HIGH(l3_rule->src_ip); rule_user->sip_low = IP_LOW(l3_rule->src_ip); rule_user->sip_high_mask = IP_HIGH(l3_rule->src_ip_mask); rule_user->sip_low_mask = IP_LOW(l3_rule->src_ip_mask); } else { rule_user->sip_high = 0; rule_user->sip_low = 0; rule_user->sip_high_mask = 0; rule_user->sip_low_mask = 0; } if (ACL_U32_BITMAP_TEST(l3_rule->rule_type, DRV_ACL_DST_IP)) { rule_user->dip_high = IP_HIGH(l3_rule->dst_ip); rule_user->dip_low = IP_LOW(l3_rule->dst_ip); rule_user->dip_high_mask = IP_HIGH(l3_rule->dst_ip_mask); rule_user->dip_low_mask = IP_LOW(l3_rule->dst_ip_mask); } else { rule_user->dip_high = 0; rule_user->dip_low = 0; rule_user->dip_high_mask = 0; rule_user->dip_low_mask = 0; } /* 目前ACL不支持配置IP协议号范围 */ if (ACL_U32_BITMAP_TEST(l3_rule->rule_type, DRV_ACL_IP_PROTOCOL)) { rule_user->proto_min = rule_user->proto_max = l3_rule->ip_protocol; } else { /* 未配置IP协议号,则范围为全部(0~255) */ rule_user->proto_min = 0; rule_user->proto_max = 255; } if (ACL_U32_BITMAP_TEST(l3_rule->rule_type, DRV_ACL_L4_SRC_PORT)) { /* 芯片ACL设计端口号范围用port/port_mask表示,现用port存port_min,port_mask存port_max */ rule_user->sport_min = l3_rule->l4_src_port; rule_user->sport_max = l3_rule->l4_src_port_mask; } else { rule_user->sport_min = 0; rule_user->sport_max = U16_MAX; } if (ACL_U32_BITMAP_TEST(l3_rule->rule_type, DRV_ACL_L4_DST_PORT)) { /* 芯片ACL设计端口号范围用port/port_mask表示,现用port存port_min,port_mask存port_max */ rule_user->dport_min = l3_rule->l4_dst_port; rule_user->dport_max = l3_rule->l4_dst_port_mask; } else { rule_user->dport_min = 0; rule_user->dport_max = U16_MAX; } data->copy_number++; /* 记录该条规则在内核规则表中的优先级 */ rule_user->node_address = gs_current_num * MAX_ACL_RULE_PER_STEP + data->copy_number; /* 填写动作位图 */ if (ACL_U32_BITMAP_TEST(acl_action[RFC_ACL_SLOT_ID][acl_rule[RFC_ACL_SLOT_ID][i].action_id].action.action_type,DROP)) { ACL_U32_BITMAP_SET(gs_action_bitmap, rule_user->node_address); } rule_user++; if (MAX_ACL_RULE_PER_STEP == data->copy_number) { gs_cur_rule_prio.port = j; goto OUT; } } gs_cur_rule_prio.port = 0;/* 从一条规则跳到下一条规则时,从其第一个端口开始遍历 */ } OUT: gs_rfc_rule_num = gs_current_num * MAX_ACL_RULE_PER_STEP + data->copy_number; gs_cur_rule_prio.rule = i + 1; if (0 == data->copy_number) /* 上一轮已取完规则,无需再下表项,故可开始匹配报文 */ { acl_rfc_ready = ACL_RFC_ALL_READY; } else { gs_current_num++; if (data->copy_number < MAX_ACL_RULE_PER_STEP) /* 规则已取完,待本轮下完表项,即可开始匹配报文 */ { acl_rfc_ready = ACL_RFC_PRE_READY; } } return ERROR_SUCCESS; }
void C_THISCLASS::smp_render(int this_thread, int max_threads, char visdata[2][2][576], int isBeat, int *framebuffer, int *fbout, int w, int h) { if (!enabled) return; unsigned int *f = (unsigned int *) framebuffer; unsigned int *of = (unsigned int *) fbout; unsigned int *lfo = (unsigned int *) lastframe; int start_l = ( this_thread * h ) / max_threads; int end_l; if (this_thread >= max_threads - 1) end_l = h; else end_l = ( (this_thread+1) * h ) / max_threads; int outh=end_l-start_l; if (outh<1) return; int skip_pix=start_l*w; f += skip_pix; of+= skip_pix; lfo += skip_pix; int at_top=0, at_bottom=0; if (!this_thread) at_top=1; if (this_thread >= max_threads - 1) at_bottom=1; timingEnter(0); { if (at_top) // top line { int x; // left edge { int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]); r += _R(f[w]); g += _G(f[w]); b += _B(f[w]); f++; r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]); lfo++; if (r < 0) r=0; else if (r > 255) r=255; if (g < 0) g=0; else if (g > 255*256) g=255*256; if (b < 0) b=0; else if (b > 255*65536) b=255*65536; *of++=_RGB(r,g,b); } // middle of line x=(w-2); while (x--) { int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]); r += _R(f[-1]); g += _G(f[-1]); b += _B(f[-1]); r += _R(f[w]); g += _G(f[w]); b += _B(f[w]); f++; r/=2; g/=2; b/=2; r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]); lfo++; if (r < 0) r=0; else if (r > 255) r=255; if (g < 0) g=0; else if (g > 255*256) g=255*256; if (b < 0) b=0; else if (b > 255*65536) b=255*65536; *of++=_RGB(r,g,b); } // right block { int r=_R(f[-1]); int g=_G(f[-1]); int b=_B(f[-1]); r += _R(f[w]); g += _G(f[w]); b += _B(f[w]); f++; r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]); lfo++; if (r < 0) r=0; else if (r > 255) r=255; if (g < 0) g=0; else if (g > 255*256) g=255*256; if (b < 0) b=0; else if (b > 255*65536) b=255*65536; *of++=_RGB(r,g,b); } } // middle block { int y=outh-at_top-at_bottom; while (y--) { int x; // left edge { int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]); r += _R(f[w]); g += _G(f[w]); b += _B(f[w]); r += _R(f[-w]); g += _G(f[-w]); b += _B(f[-w]); f++; r/=2; g/=2; b/=2; r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]); lfo++; if (r < 0) r=0; else if (r > 255) r=255; if (g < 0) g=0; else if (g > 255*256) g=255*256; if (b < 0) b=0; else if (b > 255*65536) b=255*65536; *of++=_RGB(r,g,b); } // middle of line x=(w-2); #ifdef NO_MMX while (x--) { int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]); r += _R(f[-1]); g += _G(f[-1]); b += _B(f[-1]); r += _R(f[w]); g += _G(f[w]); b += _B(f[w]); r += _R(f[-w]); g += _G(f[-w]); b += _B(f[-w]); f++; r/=2; g/=2; b/=2; r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]); lfo++; if (r < 0) r=0; else if (r > 255) r=255; if (g < 0) g=0; else if (g > 255*256) g=255*256; if (b < 0) b=0; else if (b > 255*65536) b=255*65536; *of++=_RGB(r,g,b); } #else __asm { mov esi, f mov edi, of mov edx, lfo mov ecx, x mov ebx, w shl ebx, 2 shr ecx, 1 sub esi, ebx align 16 mmx_water_loop1: movd mm0, [esi+ebx+4] movd mm1, [esi+ebx-4] punpcklbw mm0, [zero] movd mm2, [esi+ebx*2] punpcklbw mm1, [zero] movd mm3, [esi] punpcklbw mm2, [zero] movd mm4, [edx] paddw mm0, mm1 punpcklbw mm3, [zero] movd mm7, [esi+ebx+8] punpcklbw mm4, [zero] paddw mm2, mm3 movd mm6, [esi+ebx] paddw mm0, mm2 psrlw mm0, 1 punpcklbw mm7, [zero] movd mm2, [esi+ebx*2+4] psubw mm0, mm4 movd mm3, [esi+4] packuswb mm0, mm0 movd [edi], mm0 punpcklbw mm6, [zero] movd mm4, [edx+4] punpcklbw mm2, [zero] paddw mm7, mm6 punpcklbw mm3, [zero] punpcklbw mm4, [zero] paddw mm2, mm3 paddw mm7, mm2 add edx, 8 psrlw mm7, 1 add esi, 8 psubw mm7, mm4 packuswb mm7, mm7 movd [edi+4], mm7 add edi, 8 dec ecx jnz mmx_water_loop1 add esi, ebx mov f, esi mov of, edi mov lfo, edx }; #endif // right block { int r=_R(f[-1]); int g=_G(f[-1]); int b=_B(f[-1]); r += _R(f[w]); g += _G(f[w]); b += _B(f[w]); r += _R(f[-w]); g += _G(f[-w]); b += _B(f[-w]); f++; r/=2; g/=2; b/=2; r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]); lfo++; if (r < 0) r=0; else if (r > 255) r=255; if (g < 0) g=0; else if (g > 255*256) g=255*256; if (b < 0) b=0; else if (b > 255*65536) b=255*65536; *of++=_RGB(r,g,b); } } } // bottom line if (at_bottom) { int x; // left edge { int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]); r += _R(f[-w]); g += _G(f[-w]); b += _B(f[-w]); f++; r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]); lfo++; if (r < 0) r=0; else if (r > 255) r=255; if (g < 0) g=0; else if (g > 255*256) g=255*256; if (b < 0) b=0; else if (b > 255*65536) b=255*65536; *of++=_RGB(r,g,b); } // middle of line x=(w-2); while (x--) { int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]); r += _R(f[-1]); g += _G(f[-1]); b += _B(f[-1]); r += _R(f[-w]); g += _G(f[-w]); b += _B(f[-w]); f++; r/=2; g/=2; b/=2; r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]); lfo++; if (r < 0) r=0; else if (r > 255) r=255; if (g < 0) g=0; else if (g > 255*256) g=255*256; if (b < 0) b=0; else if (b > 255*65536) b=255*65536; *of++=_RGB(r,g,b); } // right block { int r=_R(f[-1]); int g=_G(f[-1]); int b=_B(f[-1]); r += _R(f[-w]); g += _G(f[-w]); b += _B(f[-w]); f++; r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]); lfo++; if (r < 0) r=0; else if (r > 255) r=255; if (g < 0) g=0; else if (g > 255*256) g=255*256; if (b < 0) b=0; else if (b > 255*65536) b=255*65536; *of++=_RGB(r,g,b); } } } memcpy(lastframe+skip_pix,framebuffer+skip_pix,w*outh*sizeof(int)); #ifndef NO_MMX __asm emms; #endif timingLeave(0); } C_RBASE *R_Water(char *desc) { if (desc) { strcpy(desc,MOD_NAME); return NULL; } return (C_RBASE *) new C_THISCLASS(); } static C_THISCLASS *g_this; static BOOL CALLBACK g_DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: if (g_this->enabled) CheckDlgButton(hwndDlg,IDC_CHECK1,BST_CHECKED); return 1; case WM_COMMAND: if (LOWORD(wParam) == IDC_CHECK1) { if (IsDlgButtonChecked(hwndDlg,IDC_CHECK1)) g_this->enabled=1; else g_this->enabled=0; } return 0; } return 0; } HWND C_THISCLASS::conf(HINSTANCE hInstance, HWND hwndParent) { g_this = this; return CreateDialog(hInstance,MAKEINTRESOURCE(IDD_CFG_WATER),hwndParent,g_DlgProc); }
RGB TorranceSparrowSpecular::f(const Intersection &sr, const Vector &wi, const Vector &wo) { Vector half=Normalize(wi + wo); return mAlbedo/(4*M_PI*Dot(sr.normal,wi))*_NDF(sr.normal,half)*_Fresnel(wo,half)*_G(sr.normal,half,wi,wo); }