#### Archived

This topic is now archived and is closed to further replies.

# Creating a projection matrix without d3dx

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

## Recommended Posts

yep, i''m the one who''d like to learn it "the hard" way before using d3dx. so far i''ve implemented my rotation and translations matrix operations, but got stuck on the viewport matrix.
memset(&m_Data, 0, sizeof(float) * 16);

float n_p = 1.0f;
float f_p = 10.0f;

float aspect = 768.0f / 1024.0f;

float w = aspect * (cosf(90.0f / 2.0f) / sin(90.0f /2.0f));
float h = 1.0f * (cosf(90.0f / 2.0f) / sin(90.0f /2.0f));
float q = f_p / (f_p - n_p);

m_Data[0]  = w; // this is the matrix._11
m_Data[5]  = h; // the matrix._22
m_Data[10] = q; // the matrix._33
m_Data[11] = 1.0f; // the matrix._34
m_Data[14] = -q * n_p; // the matrix._43


later on, i''ll convert my own matrix into a d3dmatrix and set the D3DTS_PROJECTION but something seems wrong

##### Share on other sites
Forgive me if I''m wrong, but I think there is a section in the sdk where it goes over all the maths it uses for the projection matrices, and lighting and stuff like that.