Jump to content

  • Log In with Google      Sign In   
  • Create Account


how to use two sampler in pixel shade with d3d9


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 tracegame   Members   -  Reputation: 127

Like
0Likes
Like

Posted 03 July 2012 - 02:16 AM

just beginner of d3d9,the ps code is something like this

[source lang="cpp"]sampler s_2D = sampler_state { minfilter = LINEAR; maxfilter = LINEAR;};struct PS_INPUT{ float2 tex : TEXCOORD0;};struct PS_OUTPUT{ float4 Color:COLOR;};PS_OUTPUT PS(PS_INPUT psInput){ PS_OUTPUT Out_ps = (PS_OUTPUT) 0; Out_ps.Color = tex2D(s_2D, psInput.tex); return Out_ps;}[/source]

and the code in main.cpp

[source lang="cpp"]//=========setupV_RETURN( D3DXCreateTextureFromFile( pd3dDevice, L"texture.jpg", &g_pTexture) ); pd3dDevice->SetTexture(0, g_pTexture);LPD3DXBUFFER pCode_PS; DWORD dwShaderFlags = D3DXSHADER_SKIPOPTIMIZATION|D3DXSHADER_DEBUG; V_RETURN(D3DXCompileShaderFromFile( L"HLSLTexture.psh", NULL, NULL, "PS", "ps_2_0", dwShaderFlags, &pCode_PS, NULL, &g_pConstantTable_PS));V_RETURN(pd3dDevice->CreatePixelShader( (DWORD*)pCode_PS->GetBufferPointer(), &g_pPixelShader)); pCode_PS->Release();//=====renderif( SUCCEEDED( pd3dDevice->BeginScene() ) ) { pd3dDevice->SetPixelShader( g_pPixelShader ); pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) ); pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ); pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2*50-2 ); V( pd3dDevice->EndScene() ); }[/source]

how can i use another sampler,or texture.i try to load another image in cpp


[source lang="cpp"]V_RETURN( D3DXCreateTextureFromFile( pd3dDevice, L"texture2.jpg", &g_pTexture2) );pd3dDevice->SetTexture(1, g_pTexture2);[/source]
and add another member

[source lang="cpp"]sampler s_2D = sampler_state { minfilter = LINEAR; maxfilter = LINEAR;};struct PS_INPUT{ float2 tex : TEXCOORD0; float2 tex2 : TEXCOORD1;};struct PS_OUTPUT{ float4 Color:COLOR;};PS_OUTPUT PS(PS_INPUT psInput){ PS_OUTPUT Out_ps = (PS_OUTPUT) 0; Out_ps.Color = tex2D(s_2D, psInput.tex2); return Out_ps;}[/source]

but it doesn't work,nothing shows up.what's wrong?how can i fix that?

Sponsor:

#2 Dawoodoz   Members   -  Reputation: 290

Like
0Likes
Like

Posted 03 July 2012 - 03:50 AM

Pix can show you if your resources are loaded by finding their buffers and selecting a relevant time.
http://blogs.msdn.co...or-windows.aspx

I advice you to start learning DirectX 11 instead since it support both new and old hardware.

My open source DirectX 10/11 graphics engine. https://sites.google.com/site/dawoodoz

"My design pattern is the simplest to understand. Everyone else is just too stupid to understand it."





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS