Jump to content

  • Log In with Google      Sign In   
  • Create Account


SetFloatVector()


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
3 replies to this topic

#1 lomateron   Members   -  Reputation: 300

Like
0Likes
Like

Posted 30 January 2013 - 08:15 PM

I crated this

 

ID3D10EffectVectorVariable*         g_pVe = NULL;

 

So I am trying to give a float4 variable called "Ve" in the .fx file a value.

This is the first time i have used a float4 variable. when i use float3 variables I use D3DXVECTOR3 struct like this:

 

g_pVe->SetFloatVector(D3DXVECTOR3(0.0f,0.0f,0.0f,0.0f));

 

There is no D3DXVECTOR4 struct so i did this:

 

vector<float> FloatVct(4);

grd[0]=0.0f;

grd[1]=0.0f;

grd[2]=0.0f;

grd[3]=0.0f;

 

g_pVe->SetFloatVector(&grd[0]);

 

Is this correct?

 

I am asking because I have a bug and I think this could be causing it. The bug is related with the 4th value of the float4 variable.


Edited by lomateron, 30 January 2013 - 08:17 PM.


Sponsor:

#2 L. Spiro   Crossbones+   -  Reputation: 11938

Like
1Likes
Like

Posted 30 January 2013 - 08:47 PM

That is how to set a 4-component floating-point vector, yes.

But there is no reason to use a vector<> here; you are wasting a lot of time allocating data that could just as easily be a hard-coded 4-component array on the stack.

 

 

L. Spiro


It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#3 ankhd   Members   -  Reputation: 1071

Like
0Likes
Like

Posted 31 January 2013 - 03:49 AM

there is a D3DXVECTOR4 or you could use a D3DXCOLOR



#4 Medo3337   Members   -  Reputation: 663

Like
0Likes
Like

Posted 01 February 2013 - 07:21 AM

D3DXVECTOR4 exists, here is D3DXVECTOR4 definition:
 
d3dx9math.h:
typedef struct D3DXVECTOR4
{
#ifdef __cplusplus
public:
    D3DXVECTOR4() {};
    D3DXVECTOR4( CONST FLOAT* );
    D3DXVECTOR4( CONST D3DXFLOAT16* );
    D3DXVECTOR4( CONST D3DVECTOR& xyz, FLOAT w );
    D3DXVECTOR4( FLOAT x, FLOAT y, FLOAT z, FLOAT w );

    // casting
    operator FLOAT* ();
    operator CONST FLOAT* () const;

    // assignment operators
    D3DXVECTOR4& operator += ( CONST D3DXVECTOR4& );
    D3DXVECTOR4& operator -= ( CONST D3DXVECTOR4& );
    D3DXVECTOR4& operator *= ( FLOAT );
    D3DXVECTOR4& operator /= ( FLOAT );

    // unary operators
    D3DXVECTOR4 operator + () const;
    D3DXVECTOR4 operator - () const;

    // binary operators
    D3DXVECTOR4 operator + ( CONST D3DXVECTOR4& ) const;
    D3DXVECTOR4 operator - ( CONST D3DXVECTOR4& ) const;
    D3DXVECTOR4 operator * ( FLOAT ) const;
    D3DXVECTOR4 operator / ( FLOAT ) const;

    friend D3DXVECTOR4 operator * ( FLOAT, CONST D3DXVECTOR4& );

    BOOL operator == ( CONST D3DXVECTOR4& ) const;
    BOOL operator != ( CONST D3DXVECTOR4& ) const;

public:
#endif //__cplusplus
    FLOAT x, y, z, w;
} D3DXVECTOR4, *LPD3DXVECTOR4;

Using vector for doing that is not wise, you can use D3DXVECTOR4 or make your own FLOAT4 class.






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