Skip to main content
GameDev.net gamedev.net
🔒 Locked

problem compiling .fx file!

Started by rohith291991 Dec 15, 2008 at 7:39 AM 3 replies 1.3k views
Original Post
rohith291991
rohith291991
Hi. When i call D3DXCreateEffectFromFile() it fails to compile the following HLSL code.. however when i set PixelShader=NULL; and comment out the OurFirstPixelShader() function it compiles... what could be the problem?? thanks in advance! struct VertexToPixel { float4 Position : POSITION; float2 TexCoords : TEXCOORD0; }; struct PixelToFrame { float4 Color : COLOR; }; float4x4 xViewProjection; Texture xColoredTexture; sampler ColoredTextureSampler = sampler_state { texture = ; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = mirror; AddressV = mirror;}; VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float2 inTexCoords : TEXCOORD0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.TexCoords = inTexCoords; return Output; } PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = tex2D(ColoredTextureSampler, PSIn.TexCoords); return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_1_1 SimplestVertexShader(); PixelShader = compile ps_1_1 OurFirstPixelShader(); } }
paic
paic
First of all, try using [ source ] and [ / source ] (without the spaces) to add code to your posts, it will be more readable :)

that said, I don't see anything obviously wrong with your code ... You should try to check the documentation of D3DXCreateEffectFromFile. You'll notice the last parameter allow you to get the compilation error. It will give you a lot of information (the cause of the error, the line of the error, etc.)

For example, in my program, I have something like this :

ID3DXBuffer * pErrors = NULL;ID3DXEffect * pEffect = NULL;if (FAILED(D3DXCreateEffect(d3ddevice, fileName, NULL, NULL, 0, NULL, &pEffect, &pErrors))){    std::string msg;    if (pErrors)  msg = (LPCSTR)pErrors->GetBufferPointer();    else          msg = "Unknow Error while creating the effect";    SAFE_RELEASE(pErrors);    MessageBox(NULL, msg.c_str(), "Shader::Init", MB_ICONERROR);}SAFE_RELEASE(pErrors);


So that when the compilation fails, it displays a messagebox with the cause of the fail.
rohith291991
rohith291991
i dunno what happened but it started working now!! all i did was change to retail dll in the control panel and change back to debug!! lol... thanks anyway!
jollyjeffers
jollyjeffers
Quote:
Original post by rohith291991
i dunno what happened but it started working now!! all i did was change to retail dll in the control panel and change back to debug!! lol... thanks anyway!
Glad to hear you got it working again!

For future reference it will help your case a lot if you provide us with the debug runtime and HLSL compiler output in your initial post should you need help in the future [smile]


Cheers,
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.