|
|
|
|||||||||||
|
|
|
![]() |
|
|
|
|||||||
|
|
|
|
|
|
||||||||
|
|
|
|||||||||||
|
|
|
|
|
|||||||||
Scaling our Square with Direct3DBack to Direct3D Tutorial Index Welcome to the next in my line of Direct 3D tutorials. Here you will learn how ------------------------------------------------------------------------------- This tutorial does not need any added header files, libraries or global variables. ------------------------------------------------------------------------------- I have placed all of our scaling code into the one folder to show you it Next we call the function: D3DXMatrixScaling which will take the parameters Next we tell our rendering device to transform our world in accordance to our ------------------------------------------------------------------------------ Finally we need to call our Scaling function, which is done from within our So just before your code to create your object, I have added the line: ----------------------------------------------------------------------------- If you have any queries about this tutorial, please email me at swiftless@gmail.com #include <dx/d3dx9.h> #pragma comment(lib,"d3d9.lib") LPDIRECT3D9 g_pD3D = NULL; struct CUSTOMVERTEX #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE) void init( HWND hWnd ) g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ); D3DPRESENT_PARAMETERS d3dpp; g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice ); g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE ); g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE ); } void initVBuffer (void) { 1, 1, 0, D3DCOLOR_XRGB(255,255,0), }, g_pd3dDevice->CreateVertexBuffer( 4*sizeof(CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL ); void* pVertices; memcpy( pVertices, Square, sizeof(Square) ); g_pVB->Unlock(); void Scaling (void) D3DXMatrixScaling(&matWorld, 1,2,1); g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld ); void Eye (void) D3DXMATRIXA16 mView; void Perspective (void) void Cleanup (void) if( g_pVB != NULL ) if( g_pD3D != NULL) void Render (void) Eye(); Perspective(); Scaling(); g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) ); g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 ); g_pd3dDevice->EndScene(); g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) case WM_PAINT: return DefWindowProc( hWnd, msg, wParam, lParam ); INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT ) HWND hWnd = CreateWindow( "A Basic Window", "A Basic Window", WS_OVERLAPPEDWINDOW, 100, 100, 500, 500, NULL, NULL, wc.hInstance, NULL ); init( hWnd ); initVBuffer(); ShowWindow( hWnd, SW_SHOWDEFAULT ); MSG msg; UnregisterClass( "A Basic Window", wc.hInstance ); |
|
|||||||||||
|
|
||||||||||||
|
|
||||||||||||
|
|
||||||||||||
|
|
||||||||||||
|
|
||||||||||||
|
|
||||||||||||
|
|
||||||||||||
|
|
||||||||||||
|
|
||||||||||||
|
|
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Copyright 2008, Donald Urquhart |
||||||||||||