Forum
Contact





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



Latest Forum posts

 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

 DVD to DNxHD Converter for Mac
  Posted by: VIKIVannessa
  When: 02/04/2014 at 05:46:04

 play HD Videos on Galaxy
  Posted by: Applefly
  When: 01/04/2014 at 03:16:39

 video on iPhone 6
  Posted by: Applefly
  When: 01/04/2014 at 03:15:18

 MessageBox
  Posted by: net777
  When: 31/03/2014 at 03:34:55

 Play MVI/MKV/AVI on Galaxy NotePro 12.2
  Posted by: VIKIVannessa
  When: 31/03/2014 at 01:30:21




Topic: Using shader with C++



  
Goto parent category
  
Create a new user account


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

  
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..

#define TERRAIN_FVF (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1)
struct TERRAIN_VERTEX {
    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))) {
            terrain_effect->SetTexture("xSandTexture",terrain_textures[0]);
            terrain_effect->SetTexture("xGrassTexture",terrain_textures[1]);
            terrain_effect->SetTexture("xRockTexture",terrain_textures[2]);
            terrain_effect->SetTexture("xSnowTexture",terrain_textures[3]);
    } 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
Hi,

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,
                              0,
                              D3DXSHADER_DEBUG,
                              0,
                              &myEffectPtr,
                              &errorBufferPtr
                            );
    // 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
 





Google
 
Web www.riemers.net
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


News
Home
Forum
XNA 2.0 Recipes Book (8)
XNA 3.0 Recipes Book (8)
Downloads
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
Camera
Rotation - Translation
Indices
Terrain creation
Terrain from file
DirectInput
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)