Jump to content
  • Advertisement
Sign in to follow this  

DirectX about the matrix

This topic is 2088 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello every . I am new here .

I have a problem with the understanding of view matrix .


I draw a polyline with DrawPrimitive(D3DPT_LEINSTRIP , ...) in the x-y plane . And I put the eye in (0.0f,0.0f,-10.0f) . But I can not see the image .

But when I do not set the view matrix and projection matrix , the image will display . I do not know why .


This is my vertex buffer :

void Exercise::buildVB()
    //get Direct3D Device
    IDirect3DDevice9* _pDevice = m_pD3d->getDevice();

    //craete the vertex buffer
    HR(_pDevice->CreateVertexBuffer(6 * sizeof(VertexPos),D3DUSAGE_WRITEONLY,0,

    //lock the vertex buffer
    VertexPos * _pData = NULL ;

    //set the vertex
    /*_pData[0] = VertexPos(0.0f, 0.0f, 0.0f);
    _pData[1] = VertexPos(1.0f, 0.0f, -3.0f);
    _pData[2] = VertexPos(3.0f, 0.0f, -2.0f);
    _pData[3] = VertexPos(2.0f, 0.0f, -1.0f);
    _pData[4] = VertexPos(2.5f, 0.0f, 1.0f);
    _pData[5] = VertexPos(1.0f, 0.0f, 3.0f);*/
    _pData[0] = VertexPos(0.0f, 0.0f, 0.0f);
    _pData[1] = VertexPos(0.1f, -0.3f,0.0f );
    _pData[2] = VertexPos(0.3f, -0.2f, 0.0f);
    _pData[3] = VertexPos(0.2f, -0.1f,0.0f );
    _pData[4] = VertexPos(0.25f, 0.1f,0.0f );
    _pData[5] = VertexPos(0.1f, 0.3f,0.0f );

    //unlock the vertex buffer


This is the draw method which draw the image :

void Exercise::draw()
    //get Direct3D Device
    IDirect3DDevice9* _pDevice = m_pD3d->getDevice();

    //set stream source

    //set the index

    //set the vertex declaration

    //set the world matrix
    D3DXMATRIX _worldM ;

    //set the view matrix

    //set the projection matrix

    //set the render state

    //draw the primitive


Here is my code about the view matrix and projection matrix:

void Exercise::buildViewM()
    D3DXVECTOR3 _pos(0.0f,0.0f,-10);
    D3DXVECTOR3 _target(0.0f,0.0f,0.0f);
    D3DXVECTOR3 _up(0.0f,1.0f,0.0f);

void Exercise::buildProjM()
    float _width = m_pD3d->getD3dParam().BackBufferWidth;
    float _height = m_pD3d->getD3dParam().BackBufferHeight;


Is there any problem with my code ???

I appriciate your help .


Share this post

Link to post
Share on other sites

In such cases always start out weeding options.


Turn off lightning. Turn off cull mode. Turn off zbuffer. Set Texture to NULL (yes, wireframes can be textured)


Make the camera controllable and look around :)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!