bool CanvasItemMaterial::_set(const StringName& p_name, const Variant& p_value) { if (p_name==SceneStringNames::get_singleton()->shader_shader) { set_shader(p_value); return true; } else if (p_name==SceneStringNames::get_singleton()->shading_mode) { set_shading_mode(ShadingMode(p_value.operator int())); return true; } else { if (shader.is_valid()) { StringName pr = shader->remap_param(p_name); if (!pr) { String n = p_name; if (n.find("param/")==0) { //backwards compatibility pr = n.substr(6,n.length()); } } if (pr) { VisualServer::get_singleton()->canvas_item_material_set_shader_param(material,pr,p_value); return true; } } } return false; }
i4_bool r1_dx9_class::init(i4_display_class * display) { HRESULT hResult = DD_OK; // JJ FOR TEST if (display!=i4_dx9_display) { // || !i4_dx9_display->using_accelerated_driver()) return i4_F; } d3d_device=dx9_common.device; set_color_tint(0); init_d3d_vert_buffer(); D3DDeviceInfo * info; info=dx9_common.get_driver_hardware_info(dx9_common.pD3D9,i4_dx9_display->cur_mode.adaptor_id); if (!info) { return i4_F; } if (info->Caps.TextureCaps & D3DPTEXTURECAPS_SQUAREONLY) { needs_square_textures = i4_T; } else { needs_square_textures = i4_F; } //turn zbuffering on i4_dx9_check(d3d_device->SetRenderState(D3DRS_ZENABLE,TRUE)); //turn gouraud shading on the entire time i4_dx9_check(d3d_device->SetRenderState(D3DRS_SHADEMODE,D3DSHADE_GOURAUD)); //dithering.. eh.. i4_dx9_check(d3d_device->SetRenderState(D3DRS_DITHERENABLE,TRUE)); //no monochomatic shading? //d3d_device->SetRenderState(D3DRS_MONOENABLE,FALSE); //texturemapping mode setup //d3d_device->SetRenderState(D3DRS_TEXTUREMAPBLEND,D3DTBLEND_MODULATE); //d3d_device->SetRenderState(D3DRS_TEXTUREHANDLE,0); i4_dx9_check(d3d_device->SetSamplerState(0, D3DSAMP_ADDRESSU,D3DTADDRESS_CLAMP)); i4_dx9_check(d3d_device->SetSamplerState(0, D3DSAMP_ADDRESSV,D3DTADDRESS_CLAMP)); i4_dx9_check(d3d_device->SetSamplerState(0, D3DSAMP_ADDRESSW,D3DTADDRESS_CLAMP)); //d3d_device->SetRenderState(D3DRS_TEXTUREPERSPECTIVE,1); //no automatic face culling i4_dx9_check(d3d_device->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE)); i4_dx9_check(d3d_device->SetFVF(FVF_CUSTOMVERTEX)); //setup other basic modes set_write_mode(R1_WRITE_W | R1_COMPARE_W | R1_WRITE_COLOR); //Duh, I would need this, but it's not supported on my hw... //What else can we do? //Hm... the hw supports it, but the driver says it doesn't, so //we have a lot of false errors. i4_dx9_check(d3d_device->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE)); //d3d_device->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_DISABLE); //i4_dx9_check(d3d_device->SetTextureStageState(0,D3DTSS_TEXCOORDINDEX,0); i4_dx9_check(d3d_device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE )); i4_dx9_check(d3d_device->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE )); i4_dx9_check(d3d_device->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE )); i4_dx9_check(d3d_device->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION )); i4_dx9_check(d3d_device->SetRenderState(D3DRS_LIGHTING,FALSE)); i4_dx9_check(d3d_device->SetRenderState(D3DRS_SPECULARENABLE,FALSE)); //d3d_device->SetRenderState(D3DRS_WRAP0, // D3DWRAPCOORD_0 | D3DWRAPCOORD_1); set_shading_mode(R1_COLORED_SHADING); set_alpha_mode(R1_ALPHA_DISABLED); set_filter_mode(R1_BILINEAR_FILTERING); set_z_range(0.01f,1.0f); m_dwFogColor = 0x00b5b5ff; m_dwFogMode = D3DFOG_LINEAR; m_fFogStartValue = 0.2f; m_fFogEndValue = 1.0f; m_fFogDensity = 0.5f; m_bRangeBasedFog = FALSE; //clear the viewport, initialize type thing //clear_area(0,0,639,479,0x00000000,1.0); int w=i4_dx9_display->cur_mode.xres; int h=i4_dx9_display->cur_mode.yres; clear_area(0,0,w-1,h-1,0x0,RENDER_DEFAULT_FAR_DISTANCE); //if we're page flipping, flip so we can clear the other page initially as well i4_dx9_display->flush(); //clear_area(0,0,639,479,0x00000000,1.0); clear_area(0,0,w-1,h-1,0x0,RENDER_DEFAULT_FAR_DISTANCE); tmanager = new r1_dx9_texture_class(display->get_palette()); tmanagers.reallocate(10,10); r1_name_cache_file("dx9"); default_state(); return i4_T; }