DirectX 10 simple effect issue,bombs out after failing to load fx file

  • (2 Pages)
  • +
  • 1
  • 2

21 Replies - 938 Views - Last Post: 12 January 2013 - 12:50 PM Rate Topic: -----

#1 gruffy  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 106
  • Joined: 28-April 11

DirectX 10 simple effect issue,bombs out after failing to load fx file

Posted 07 January 2013 - 07:47 PM

HI all and thanks for reading.
I have been taking in lots of tuts (most notable influence was Excellent DX10 Tutorial Site) and have probably missed something really silly here as it is now 02:20 in the a.m. for me and ive been at it since early this afternoon.

Reason for question: I put a manager class in to keep direct x out of winMain, and to start a hopeful journey by which to have my own directX template to work from (leaving simple sample behind)

Problem: I cant seem to load the effect(fx) file. Like I stated, probably something waaaay too obvious to the eagle-eyed amongst you but , if anybody could help or point out the stupidity of my mistake with a constructive reasoning, well.
It would really really help.
Thanks once again for reading this.

Zipped vs2010 solution can be found here MyOOD3Dx10Template
(it obviously needs to be built and the additional libs and includes need to be specified in the properties but im thinking eggs, teaching to suck etc, especially for someone who`s gonna be able to solve this, lol)

Problem Code below (please excuse any weird comments, this has been a work in progress so not culled for pointless starting off comments)

the program bums out after it attempts to load an effect from file around about line 126 on here i think


#include "ManageD3DX.h"

#include <iostream>
using namespace std;

/*Gruffy 2012 - OODirectX*/


	//create the actual D3Ddevvice and swapchain
	if (FAILED  (D3D10CreateDeviceAndSwapChain(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, D3D10_SDK_VERSION, &swapChainDesc, &p_swapChain, &p_d3dDevice)))
		return err(L"D3D could not create, this message will self destruct in 5, 4, 3, 2 ...");

	/*END SWAPCHAIN AND D3D DEVICE SETUP*/

		//SHADER STAGE
	//*****************************************************************************
		
	//Load Basic Effect and Technique 
	//--------------------------------------------------------------
	if ( FAILED( D3DX10CreateEffectFromFile(	L"basicEffect.fx", 
												NULL, NULL, 
												"fx_4_0", 
												D3D10_SHADER_ENABLE_STRICTNESS, 
												0, 
												p_d3dDevice, 
												NULL, 
												NULL, 
												&p_basicEffect, 
												NULL, 
												NULL	) ) ) 
												return err(L"Could not load effect file!");	

	p_basicTechnique = p_basicEffect->GetTechniqueByName("renderTheScene");
	
	//create matrix effect pointers
	p_viewMatEffectVar = p_basicEffect->GetVariableByName( "View" )->AsMatrix();
	p_projMatEffectVar = p_basicEffect->GetVariableByName( "Projection" )->AsMatrix();
	p_worldMatEffectVar = p_basicEffect->GetVariableByName( "World" )->AsMatrix();

	//INPUT ASSEMBLY STAGE
	//*****************************************************************************




Hi guys code changed to suit request. Though as given, the full project is there, if anyone felt like running it- the problem still happens during load of the effect file failure /success call.
Many thanks for quick replies here dudes.

This post has been edited by gruffy: 08 January 2013 - 04:04 AM


Is This A Good Question/Topic? 0
  • +

Replies To: DirectX 10 simple effect issue,bombs out after failing to load fx file

#2 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: DirectX 10 simple effect issue,bombs out after failing to load fx file

Posted 07 January 2013 - 09:21 PM

Can you post the code on and around line 126 please (ten or so lines either way). Just dumping your entire project and largely irrelevant code is not really helpful to us. :)
Was This Post Helpful? 0
  • +
  • -

#3 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 998
  • View blog
  • Posts: 4,173
  • Joined: 14-February 08

Re: DirectX 10 simple effect issue,bombs out after failing to load fx file

Posted 08 January 2013 - 02:09 AM

Either the project cannot find the fx file, make sure it is in the correct location you are loading from. Or there is a problem with the .fx file, if it has errors then it will not load correctly.
Was This Post Helpful? 0
  • +
  • -

#4 gruffy  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 106
  • Joined: 28-April 11

Re: DirectX 10 simple effect issue,bombs out after failing to load fx file

Posted 08 January 2013 - 04:06 AM

View PostButchDean, on 07 January 2013 - 09:21 PM, said:

Can you post the code on and around line 126 please (ten or so lines either way). Just dumping your entire project and largely irrelevant code is not really helpful to us. :)/>



Hi Butchdean, code changed to suit request. Though as can be found in post, the full project is there, if anyone felt like running it- the problem still happens during load of the effect file failure /success call.
Many thanks for quick replies here dudes.
Thanks again
Gruffy
Was This Post Helpful? 0
  • +
  • -

#5 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 998
  • View blog
  • Posts: 4,173
  • Joined: 14-February 08

Re: DirectX 10 simple effect issue,bombs out after failing to load fx file

Posted 08 January 2013 - 04:15 AM

Please post your fx file
Was This Post Helpful? 0
  • +
  • -

#6 gruffy  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 106
  • Joined: 28-April 11

Re: DirectX 10 simple effect issue,bombs out after failing to load fx file

Posted 08 January 2013 - 05:46 AM

View Poststayscrisp, on 08 January 2013 - 04:15 AM, said:

Please post your fx file


Hey bud, here is full basicEffect.fx file.
Thanks muchly
Gruffy


//basic efffect file 
//this file is used by the shader to determine how to shade a matrix and any corresponding transforms and transitions it makes in our 3d world

<pre>matrix World;
matrix View;
matrix Proj;

struct PS_INPUT
{
	float4 Pos : SV_POSITION;
	float4 Colour : COLOR0;	//uk/us/uk/us/uk/us/uk...okay for the sake of keeping this shader UK stylee, ive used colour, sorry to anyone from the us that finds this a disappointment 
};

//vertex shader

PS_INPUT VS(float4 Pos : POSITION, float4 Colour : COLOR)
{
	PS_INPUT psInput;

	Pos = mul(Pos, World);
	Pos = mul(Pos, View);
	psInput.Pos = mul(Pos, Proj);
	psInput.Color = colour
	
	return psInput;
}

//pixel shader

float4 PS(PS_INPUT) : SV_Target
{
	return psInput.Color;
}

//render technique - we are rendering technique10

technique10 Render
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_4_0, VS()));
		SetGeometryShader(NULL);
		SetPoixelShader(CompileShader(ps_4_0, PS()));
	}
}


Was This Post Helpful? 0
  • +
  • -

#7 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 998
  • View blog
  • Posts: 4,173
  • Joined: 14-February 08

Re: DirectX 10 simple effect issue,bombs out after failing to load fx file

Posted 08 January 2013 - 06:09 AM

Doh! looks like the author of that tutorial left some HTML in there

<pre>


Is not HLSL. Remove it.
Was This Post Helpful? 0
  • +
  • -

#8 gruffy  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 106
  • Joined: 28-April 11

Re: DirectX 10 simple effect issue,bombs out after failing to load fx file

Posted 08 January 2013 - 07:13 AM

View Poststayscrisp, on 08 January 2013 - 06:09 AM, said:

Doh! looks like the author of that tutorial left some HTML in there

<pre>


Is not HLSL. Remove it.



LOL, , I added that bit in cos i thought that might be what was wrong.
will take it ouot, but think i am still getting fx issue .
Thanks though, will post back in a mo


*post "<pre>" removal*

Yeah issue still arises unfortuantely.

As far as i can make out, the effect file is good, the code is good, but it is still failing to load three vertices (triangle)and an fx file. hmmmmmmmmmm.
Can I ask, would I be better to move into directx11, or should i expect to get the same issues with that framework?

This post has been edited by gruffy: 08 January 2013 - 07:23 AM

Was This Post Helpful? 0
  • +
  • -

#9 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 998
  • View blog
  • Posts: 4,173
  • Joined: 14-February 08

Re: DirectX 10 simple effect issue,bombs out after failing to load fx file

Posted 08 January 2013 - 07:45 AM

If it fails on loading the file it almost certain to be issues in the fx file

Another issue:
float4 Colour : COLOR0;

PS_INPUT VS(float4 Pos : POSITION, float4 Colour : COLOR)

psInput.Color = colour



You are using Color, Colour and colour interchangeably.
Was This Post Helpful? 0
  • +
  • -

#10 gruffy  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 106
  • Joined: 28-April 11

Re: DirectX 10 simple effect issue,bombs out after failing to load fx file

Posted 09 January 2013 - 07:58 AM

View Poststayscrisp, on 08 January 2013 - 07:45 AM, said:

If it fails on loading the file it almost certain to be issues in the fx file

Another issue:
float4 Colour : COLOR0;

PS_INPUT VS(float4 Pos : POSITION, float4 Colour : COLOR)

psInput.Color = colour



You are using Color, Colour and colour interchangeably.


changed to this, no imporvement unfortuantely.
I also changed the last line in the technique at the bottom from SetPioxelShader to SetPixelShader as it should be (my bad there)
Is there any chance of one of you lovely fellows downloading my zipped solution, and checking out the implementation of the shader in my ManageD3DX class? as I may be loading it wrong or something, ot that I can tell at this stage, it all looks right :(

float4 Position: SV_POSITION;
float4 Color : COLOR0;

PS_INPUT VS(float4 Pos : POSITION, float4 Color : COLOR)

psInput.Color = color



Hope thats the right thing to do with above btw
Was This Post Helpful? 0
  • +
  • -

#11 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 998
  • View blog
  • Posts: 4,173
  • Joined: 14-February 08

Re: DirectX 10 simple effect issue,bombs out after failing to load fx file

Posted 09 January 2013 - 08:40 AM

Nope, you are still using

psInput.Color = color



Where do you think the 'color' variable is? it doesn't exist. Here is the correct code:

float4 Position: SV_POSITION;
float4 Color : COLOR0;

PS_INPUT VS(float4 Pos : POSITION, float4 Color : COLOR) // notice it's passing in Color, not color

psInput.Color = Color;


Was This Post Helpful? 0
  • +
  • -

#12 gruffy  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 106
  • Joined: 28-April 11

Re: DirectX 10 simple effect issue,bombs out after failing to load fx file

Posted 09 January 2013 - 10:44 AM

View Poststayscrisp, on 09 January 2013 - 08:40 AM, said:

Where do you think the 'color' variable is? it doesn't exist. Here is the correct code:



psInput.Color = Color;



sorry stayscrisp for being a total total idiot there, again my noob debugging skills didnt pick up the Caps difference.
However. With my shader rewritten including the above changes, unfortunatley I still get my shader error at runtime.
Here is the addended shader code

matrix World, View, Proj;

struct PS_INPUT
{
float4 Pos : SV_POSITION;
float4 Col : COLOR0;

};

//vs
PS_INPUT VS( float4 pos : POSITION, float4 Col : COLOR)
{
  PS_INPUT psInput;
  
  Pos = mul(Pos, World);
  Pos = mul(Pos, View);
psInput.Pos = mul(Pos, Proj);
psInput.Color = Col;

return psInput;
}

//ps
float4 PS() : SV_Target
{
  return psInput.Color;
}

//rend technique
tecnique10 Render
{
  pass P0
  {
    SetVertexShader(CompileShader(vs_4_0, VS()));
    SetGeometryShader(NULL);
    SetPixelShader(CompileShader(Ps_4_0, PS()));
  }
}



This post has been edited by gruffy: 09 January 2013 - 11:08 AM

Was This Post Helpful? 0
  • +
  • -

#13 gruffy  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 106
  • Joined: 28-April 11

Re: DirectX 10 simple effect issue,bombs out after failing to load fx file

Posted 09 January 2013 - 01:18 PM

OKay,
I have the shader file working now but am still not seeing my triangle.

Alongside this , the window flaags a message informing me the window is no longer responding withthe three options s always in this Windows 7 program "Not Responding" type scenario.
Any help along with this would be amazing or do i need to start another thread petaining specifically to this next issue (which i, personally, think is relevant to topic )
:(/>
Gruffy
:)/>

Sorry the above isnt that clear is it.

Compiles, runs (but no triangle appears and instead of black background, the screen is white), bums outs with window not responding message from the os(Win 7)

This post has been edited by gruffy: 09 January 2013 - 01:20 PM

Was This Post Helpful? 0
  • +
  • -

#14 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 998
  • View blog
  • Posts: 4,173
  • Joined: 14-February 08

Re: DirectX 10 simple effect issue,bombs out after failing to load fx file

Posted 09 January 2013 - 01:45 PM

Post your loading code again please :)
Was This Post Helpful? 0
  • +
  • -

#15 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 998
  • View blog
  • Posts: 4,173
  • Joined: 14-February 08

Re: DirectX 10 simple effect issue,bombs out after failing to load fx file

Posted 09 January 2013 - 02:51 PM

Are you still using this
 p_basicTechnique = p_basicEffect->GetTechniqueByName("renderTheScene");



As your technique is called Render

tecnique10 Render


Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2