DirectX using C#
DirectX using C++
DirectX using Visual Basic

Latest Forum posts

 Account settings
  Posted by: igthorn
  When: 21/04/2014 at 10:20:00

 Pavtube 2014 Easter Deals with 20% off
  Posted by: igthorn
  When: 21/04/2014 at 10:16:23

 20% off on iMedia Converter for Mac
  Posted by: VIKIVannessa
  When: 20/04/2014 at 01:35:54

 Pavtube Video Converter Ultimate Deal
  Posted by: VIKIVannessa
  When: 20/04/2014 at 01:35:50

 Easter Day Deals
  Posted by: Applefly
  When: 19/04/2014 at 22:18:14

 40% OFF Pavtube DVD Ripper for Mac
  Posted by: VIKIVannessa
  When: 19/04/2014 at 02:02:54

 DVD Ripper with 40% off
  Posted by: VIKIVannessa
  When: 19/04/2014 at 02:02:22

 Get DVD Ripper Wind/Mac + $14 Coupon
  Posted by: VIKIVannessa
  When: 19/04/2014 at 02:02:03

 Backup DVD Escape Plan
  Posted by: Applefly
  When: 17/04/2014 at 06:00:12

 Disney DVDs to MP4
  Posted by: Applefly
  When: 17/04/2014 at 05:56:07

 DVD movies through media streamer
  Posted by: VIKIVannessa
  When: 16/04/2014 at 02:25:09

 DVD movies to play on Galaxy Tab 3 10.1
  Posted by: VIKIVannessa
  When: 16/04/2014 at 02:20:51

 Blu-ray to Apple ProRes
  Posted by: Applefly
  When: 12/04/2014 at 00:47:46

 HD H.264 MP4 format
  Posted by: Applefly
  When: 12/04/2014 at 00:43:23

 DVD collection to computer
  Posted by: VIKIVannessa
  When: 04/04/2014 at 07:13:33

 DVD movies to play on Galaxy Tab 3 10.1
  Posted by: VIKIVannessa
  When: 04/04/2014 at 07:11:27

 DVD movies to play on Galaxy Tab 3 10.1
  Posted by: VIKIVannessa
  When: 04/04/2014 at 07:11:27

 DVD Ripper to populate
  Posted by: Applefly
  When: 04/04/2014 at 05:01:35

 kids and family watch DVD
  Posted by: Applefly
  When: 04/04/2014 at 04:59:21

 Blu-ray movie for your lovely kids
  Posted by: VIKIVannessa
  When: 02/04/2014 at 05:47:49

Topic: Using shader with C++

Goto parent category
Create a new user account

   Using shader with C++
 Poster : MetalHead
 Posts: 3
 Country : UK

Posted by MetalHead on 07/08/2007 at 09:41:41
I've been porting all the advanced terrain stuff back to C++, managed to do it perfectly so far but im having problems simply loading this .fx file.

My vertex format is identical..

    D3DXVECTOR3 Position;
    D3DXVECTOR3 Normal;
    D3DXVECTOR4 TextureCoordinate;
    D3DXVECTOR4 TexWeights;

And i'm attempting to load the .fx file via..

    //load the FX file
    if (SUCCEEDED(D3DXCreateEffectFromFile(g_d3d_dev,L"fx/terrain.fx",NULL,NULL,0,NULL,&terrain_effect,NULL))) {
    } else {
            MessageBox(g_hWnd,L"Error trying to open terrain fx file, will render without shaders",L"terrain_init()",MB_OK);
            terrain_effect = NULL;

Any ideas why it's failing when I try to create it?

Thanks in advance, my source will be available once it's all done.
 Poster : Carlos
 Posts: 1
 Country : Hungary
 City: Dunakeszi

Posted by Carlos on 23/01/2009 at 04:40:13

In order to check what's wrong with loading the effect file, I recommend to display the error message - which is currently skipped in your code - in the MessagBox. Example:

// load effect from file
    ID3DXBuffer* errorBufferPtr = NULL;
    D3DXCreateEffectFromFile( myD3DDevicePtr,
                              effect.fx, // effect file name                              0,
    // effect loading failure
    if( errorBufferPtr )
        MessageBox( 0, (char*)errorBufferPtr->GetBufferPointer(), 0, 0 );

Whjat I don' really get is why are you troubling with the FVF, as it is meant for the fixed pipeline, not for the shader-based approach. (Furthermore the FVF which you specified does not reflect the real vertex structure, just check it out, but rather just delete it! ;-))
You should set the data interface between the app and the effect file using CreateVertexDeclaration() then set it using SetVertexDeclaration() before rendering.

Hope this helps!

Post a new reply

If you appreciate the amount of time I spend creating and updating
these pages, feel free to donate -- any amount is welcome !
- Website design & DirectX code : Riemer Grootjans -
©2006 Riemer Grootjans

XNA 2.0 Recipes Book (8)
XNA 3.0 Recipes Book (8)
Extra Reading (3)
Matrices: geometrical
Matrix Mathematics
Homogenous matrices
Community Projects (1)
Tutorials (160)
XNA 4.0 using C# (89)
DirectX using C# (54)
Series 1:Terrain (14)
Opening a window
Linking to the Device
Drawing a triangle
Rotation - Translation
Terrain creation
Terrain from file
Importing bmp files
Colored vertices
DirectX Light basics
Mesh creation
Mesh lighting
Series 2: Flightsim (19)
Series 3: HLSL (19)
Short Tuts (2)
Resizing problem
Checking Device caps
DirectX using C++ (15)
DirectX using VB (2)