#define WIN32_LEAN_AND_MEAN
#define VC_LEANMEAN
#include <windows.h>
#include <d3d9.h>
#include <d3dx9.h>
#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib")
#define CLASS_NAME "Project1"
#define WIN_NAME "Building An Engine"
#define D3DFVF_CUSTOME (D3DFVF_XYZ | D3DFVF_DIFFUSE)
HWND g_hwnd = NULL;
LPDIRECT3D9 d3d_object = NULL;
LPDIRECT3DDEVICE9 d3d_device = NULL;
LPDIRECT3DVERTEXBUFFER9 VB_Triangle = NULL;
LPDIRECT3DVERTEXBUFFER9 VB_Quad = NULL;
bool Init3D();
void InitObj();
void Init2DObj();
void Render();
void SetCamera();
void Set2DCamera();
void SetRotation();
void SetPerspective();
void Kill3D();
struct Vertex
{
float x,y,z;
DWORD color;
};
float angle = 0.0f;
LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
switch(message)
{
case WM_KEYUP:
if(wparam == VK_ESCAPE)
PostQuitMessage(0);
break;
case WM_CLOSE:
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd, message, wparam, lparam);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX winclass;
MSG msg;
ZeroMemory(&msg, sizeof(msg));
winclass.cbClsExtra=0;
winclass.cbSize=sizeof(WNDCLASSEX);
winclass.cbWndExtra=0;
winclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
winclass.hCursor=LoadCursor(NULL, IDC_ARROW);
winclass.hIcon=LoadIcon(NULL, IDI_APPLICATION);
winclass.hIconSm=NULL;
winclass.hInstance=hInstance;
winclass.lpfnWndProc=WinProc;
winclass.lpszClassName=CLASS_NAME;
winclass.lpszMenuName=NULL;
winclass.style=CS_HREDRAW | CS_VREDRAW;
RegisterClassEx(&winclass);
g_hwnd = CreateWindowEx( NULL,
CLASS_NAME,
WIN_NAME,
WS_OVERLAPPEDWINDOW | WS_SYSMENU | WS_VISIBLE,
100,100,
640,480,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(g_hwnd, nCmdShow);
UpdateWindow(g_hwnd);
Init3D();
while(msg.message != WM_QUIT)
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
Render();
}
Kill3D();
UnregisterClass(CLASS_NAME, winclass.hInstance);
return (int)msg.wParam;
}
bool Init3D()
{
D3DDISPLAYMODE display;
D3DCAPS9 caps;
D3DPRESENT_PARAMETERS pp;
ZeroMemory(&pp, sizeof(pp));
d3d_object = Direct3DCreate9(D3D_SDK_VERSION);
if(FAILED(d3d_object->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &display)))
return false;
if(FAILED(d3d_object->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &caps)))
return false;
DWORD VertexProcessing =0;
if(caps.VertexProcessingCaps != 0)
VertexProcessing |= D3DCREATE_HARDWARE_VERTEXPROCESSING;
else
VertexProcessing |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
pp.Windowed=true;
pp.BackBufferFormat=display.Format;
pp.BackBufferHeight=480;
pp.BackBufferHeight=640;
pp.EnableAutoDepthStencil=true;
pp.AutoDepthStencilFormat=D3DFMT_D16;
pp.SwapEffect=D3DSWAPEFFECT_DISCARD;
if(FAILED(d3d_object->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
g_hwnd, VertexProcessing, &pp, &d3d_device)))
return false;
d3d_device->SetRenderState(D3DRS_LIGHTING, FALSE);
d3d_device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
d3d_device->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
InitObj();
SetPerspective();
return true;
}
void InitObj()
{
Vertex Triangle[] =
{
{ -0.5f, -0.5f, 0.0f, D3DCOLOR_COLORVALUE(1,0,0,0)},
{ 0.5f, -0.5f, 0.0f, D3DCOLOR_COLORVALUE(1,0,0,0)},
{ 0.0f, 0.5f, 0.5f, D3DCOLOR_COLORVALUE(1,0,0,0)},
{ 0.5f, -0.5f, 0.0f, D3DCOLOR_COLORVALUE(1,1,0,0)},
{ 0.5f, -0.5f, 1.0f, D3DCOLOR_COLORVALUE(1,1,0,0)},
{ 0.0f, 0.5f, 0.5f, D3DCOLOR_COLORVALUE(1,1,0,0)},
{ -0.5f, -0.5f, 1.0f, D3DCOLOR_COLORVALUE(1,0,1,0)},
{ 0.5f, -0.5f, 1.0f, D3DCOLOR_COLORVALUE(1,0,1,0)},
{ 0.0f, 0.5f, 0.5f, D3DCOLOR_COLORVALUE(1,0,1,0)},
{ -0.5f, -0.5f, 0.0f, D3DCOLOR_COLORVALUE(1,1,0,0)},
{ -0.5f, -0.5f, 1.0f, D3DCOLOR_COLORVALUE(1,0,1,0)},
{ 0.0f, 0.5f, 0.5f, D3DCOLOR_COLORVALUE(1,1,0,0)}
};
d3d_device->CreateVertexBuffer( sizeof(Triangle), 0, D3DFVF_CUSTOME, D3DPOOL_DEFAULT, &VB_Triangle,
NULL);
Vertex *Vertices;
VB_Triangle->Lock(0, sizeof(Triangle), (void**)&Vertices, 0);
memcpy(Vertices,Triangle, sizeof(Triangle));
VB_Triangle->Unlock();
}
void Init2DObj()
{
Vertex Quad[] =
{
{ -0.5f, 0.5f, 0.0f, D3DCOLOR_COLORVALUE(1,0,0,0)},
{ -0.5f, -0.5f, 0.0f, D3DCOLOR_COLORVALUE(1,0,0,0)},
{ 0.5f, -0.5f, 0.0f, D3DCOLOR_COLORVALUE(1,0,0,0)},
{ 0.5f, 0.5f, 0.0f, D3DCOLOR_COLORVALUE(1,0,0,0)}
};
d3d_device->CreateVertexBuffer(sizeof(Quad), 0, D3DFVF_CUSTOME, D3DPOOL_DEFAULT, &VB_Quad, NULL);
Vertex *Vertices;
VB_Quad->Lock(0, sizeof(Quad), (void**)&Vertices, 0);
memcpy(Vertices, Quad, sizeof(Quad));
VB_Quad->Unlock();
}
void SetRotation()
{
D3DXMATRIXA16 World;
D3DXMatrixRotationY(&World, angle);
d3d_device->SetTransform(D3DTS_WORLD, &World);
angle += 0.01f;
}
void SetCamera()
{
D3DXMATRIXA16 View;
D3DXVECTOR3 Eye(0.0f, 0.0f, -5.0f);
D3DXVECTOR3 LookAt(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 Up(0.0f, 1.0f, 0.0f);
D3DXMatrixLookAtLH(&View, &Eye, &LookAt, &Up);
d3d_device->SetTransform(D3DTS_VIEW, &View);
}
void Set2DCamera()
{
D3DXMATRIXA16 matOrtho;
D3DXMATRIXA16 matIdentity;
//setup the orthogonal projection matrix and the default world/view
D3DXMatrixOrthoLH(&matOrtho, 640, 480, 0.0f, 1.0f);
D3DXMatrixIdentity(&matIdentity);
d3d_device->SetTransform(D3DTS_PROJECTION, &matOrtho);
d3d_device->SetTransform(D3DTS_WORLD, &matIdentity);
d3d_device->SetTransform(D3DTS_VIEW, &matIdentity);
//make sure zbuffer is disable
d3d_device->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
d3d_device->SetRenderState(D3DRS_LIGHTING, FALSE);
}
void SetPerspective()
{
D3DXMATRIXA16 Projection;
D3DXMatrixPerspectiveFovLH(&Projection, 1.0f, 640/480, 0.0f, 500.0f);
d3d_device->SetTransform(D3DTS_PROJECTION, &Projection);
}
void Render()
{
d3d_device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_COLORVALUE(0,0,0,0), 1.0f, 0);
d3d_device->BeginScene();
SetRotation();
SetCamera();
d3d_device->SetStreamSource(0, VB_Triangle, 0, sizeof(Vertex));
d3d_device->SetFVF(D3DFVF_CUSTOME);
d3d_device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 4);
Init2DObj();
Set2DCamera();
d3d_device->SetStreamSource(0, VB_Quad, 0, sizeof(Vertex));
d3d_device->SetFVF(D3DFVF_CUSTOME);
d3d_device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
d3d_device->EndScene();
d3d_device->Present(NULL, NULL, NULL, NULL);
}
void Kill3D()
{
if(VB_Quad != NULL)
{
VB_Quad->Release();
VB_Quad = NULL;
}
if(VB_Triangle != NULL)
{
VB_Triangle ->Release();
VB_Triangle = NULL;
}
if(d3d_device != NULL)
{
d3d_device->Release();
d3d_device = NULL;
}
if(d3d_object != NULL)
{
d3d_object->Release();
d3d_object=NULL;
}
}
how do you create a menu????
Init3D(); //create 3d device
Init3DObj(); //create 3d object
Init2DObj(); //create 2d object
SetRotation(); //set rotation for 3D Tri
SetCamera(); //set the View for the 3D Tri
Set2DCamera(); //camera without ZBUFFER for like button
SetPerspective(); //for 3D Tri
any one know a tutorial that help draw a menu???
I am tryin to draw a square(button) with a rotation 3D Tri as background.
here is the code i did.
[Edited by - VertexNormal on April 24, 2005 8:39:54 PM]
WHoah, ok first of all taggify ur source:
[source ][source/ ] (without the trailing space)I recommend just drawing a quad to the screen that changes backround when the mouse is over down and up, this will help you link together the important elements of 2D picking. Dont worry about the rotating trinagle for now.ace
Right here are your problems and solutiong, but promise me form now on you'll post your actual quest aswell as your code :)
1.
D3DXMatrixPerspectiveFovLH(&Projection, 1.0f, 640/480, 0.0f, 500.0f);
to
D3DXMatrixPerspectiveFovLH(&Projection, 45.0f, Width/Height, 0.0f, 500.0f);
1.0 is a crazy fov, not a desperate bug however, just a little change :)
2.
You use 640 and 480 for your width and heights but the actual; area of the window is smaller. To fix you need the following. Two global variables (as you have no problem using them) called width and height. Then after you make your window and before Init3D() place the following:
RECT R;
GetClientRect(g_hwnd,&R);
Width = R.right;
Height = R.bottom;
3.
The triangles will not appear as you change the camera to 2d mode but never change it back. Change your matrice setup to
SetPerspective();
SetRotation();
SetCamera();
Before you draw your triangles.
4.
As for the 2D rectangle. First remove the Init2DObj call from the render loop and place it with the InitObj call, though Im guessing this is acidental left over mess around til it works code.
Now Ive gone ahead and made the code alittle different so bear with me. I changed the creation code to:
This will make us a 2d rectangle 20 pixels wide.
Then we change the setup 2d camera to
Or in other words by changing X and Y we can move the rectangle around the screen. obviously the changes arn't finished and are left up to you to change how you want.
Anyway I lost count of the bug fixes and changes so Ill post again witha copy n paste of the finished thing, you can check that for changes.
1.
D3DXMatrixPerspectiveFovLH(&Projection, 1.0f, 640/480, 0.0f, 500.0f);
to
D3DXMatrixPerspectiveFovLH(&Projection, 45.0f, Width/Height, 0.0f, 500.0f);
1.0 is a crazy fov, not a desperate bug however, just a little change :)
2.
You use 640 and 480 for your width and heights but the actual; area of the window is smaller. To fix you need the following. Two global variables (as you have no problem using them) called width and height. Then after you make your window and before Init3D() place the following:
RECT R;
GetClientRect(g_hwnd,&R);
Width = R.right;
Height = R.bottom;
3.
The triangles will not appear as you change the camera to 2d mode but never change it back. Change your matrice setup to
SetPerspective();
SetRotation();
SetCamera();
Before you draw your triangles.
4.
As for the 2D rectangle. First remove the Init2DObj call from the render loop and place it with the InitObj call, though Im guessing this is acidental left over mess around til it works code.
Now Ive gone ahead and made the code alittle different so bear with me. I changed the creation code to:
Vertex Quad[] = { { 0.0f , -20.0f , 0.0f, D3DCOLOR_COLORVALUE(1,0,0,0)}, { 0.0f , 0.0f, 0.0f, D3DCOLOR_COLORVALUE(1,0,0,0)}, { 20.0f, -20.0f, 0.0f, D3DCOLOR_COLORVALUE(1,0,0,0)}, { 20.0f, 0.0f, 0.0f, D3DCOLOR_COLORVALUE(1,0,0,0)} };
This will make us a 2d rectangle 20 pixels wide.
Then we change the setup 2d camera to
float X = 1; float Y = 1; D3DXMATRIXA16 matOrtho; D3DXMATRIXA16 matIdentity; D3DXMATRIXA16 World; //setup the orthogonal projection matrix and the default world/view D3DXMatrixOrthoLH(&matOrtho, Width,Height, 0.0f, 1.0f); D3DXMatrixIdentity(&matIdentity); d3d_device->SetTransform(D3DTS_PROJECTION, &matOrtho); d3d_device->SetTransform(D3DTS_VIEW, &matIdentity); D3DXMatrixTranslation(&World,X - ((float)Width/2.0f),((float)Height/2.0f) - Y,0); d3d_device->SetTransform( D3DTS_WORLD, &World); d3d_device->SetRenderState(D3DRS_LIGHTING, FALSE);
Or in other words by changing X and Y we can move the rectangle around the screen. obviously the changes arn't finished and are left up to you to change how you want.
Anyway I lost count of the bug fixes and changes so Ill post again witha copy n paste of the finished thing, you can check that for changes.
Working version in full
#define WIN32_LEAN_AND_MEAN#define VC_LEANMEAN#include <windows.h>#include <d3d9.h>#include <d3dx9.h>#pragma comment (lib, "d3d9.lib")#pragma comment (lib, "d3dx9.lib")#define CLASS_NAME "Project1"#define WIN_NAME "Building An Engine"#define D3DFVF_CUSTOME (D3DFVF_XYZ | D3DFVF_DIFFUSE)HWND g_hwnd = NULL;LPDIRECT3D9 d3d_object = NULL;LPDIRECT3DDEVICE9 d3d_device = NULL;LPDIRECT3DVERTEXBUFFER9 VB_Triangle = NULL;LPDIRECT3DVERTEXBUFFER9 VB_Quad = NULL;bool Init3D();void InitObj();void Init2DObj();void Render();void SetCamera();void Set2DCamera();void SetRotation();void SetPerspective();void Kill3D();struct Vertex{ float x,y,z; DWORD color;};float angle = 0.0f;int Width = 640;int Height = 480;LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam){ switch(message) { case WM_KEYUP: if(wparam == VK_ESCAPE) PostQuitMessage(0); break; case WM_CLOSE: case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hwnd, message, wparam, lparam);}int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ WNDCLASSEX winclass; MSG msg; ZeroMemory(&msg, sizeof(msg)); winclass.cbClsExtra=0; winclass.cbSize=sizeof(WNDCLASSEX); winclass.cbWndExtra=0; winclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH); winclass.hCursor=LoadCursor(NULL, IDC_ARROW); winclass.hIcon=LoadIcon(NULL, IDI_APPLICATION); winclass.hIconSm=NULL; winclass.hInstance=hInstance; winclass.lpfnWndProc=WinProc; winclass.lpszClassName=CLASS_NAME; winclass.lpszMenuName=NULL; winclass.style=CS_HREDRAW | CS_VREDRAW; RegisterClassEx(&winclass); g_hwnd = CreateWindowEx( NULL, CLASS_NAME, WIN_NAME, WS_OVERLAPPEDWINDOW | WS_SYSMENU | WS_VISIBLE, 100,100, 640,480, NULL, NULL, hInstance, NULL); ShowWindow(g_hwnd, nCmdShow); UpdateWindow(g_hwnd); RECT R; GetClientRect(g_hwnd,&R); Width = R.right; Height = R.bottom; Init3D(); while(msg.message != WM_QUIT) { if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else Render(); } Kill3D(); UnregisterClass(CLASS_NAME, winclass.hInstance); return (int)msg.wParam;}bool Init3D(){ D3DDISPLAYMODE display; D3DCAPS9 caps; D3DPRESENT_PARAMETERS pp; ZeroMemory(&pp, sizeof(pp)); d3d_object = Direct3DCreate9(D3D_SDK_VERSION); if(FAILED(d3d_object->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &display))) return false; if(FAILED(d3d_object->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &caps))) return false; DWORD VertexProcessing =0; if(caps.VertexProcessingCaps != 0) VertexProcessing |= D3DCREATE_HARDWARE_VERTEXPROCESSING; else VertexProcessing |= D3DCREATE_SOFTWARE_VERTEXPROCESSING; pp.Windowed=true; pp.BackBufferFormat=display.Format; pp.BackBufferWidth=Width; pp.BackBufferHeight=Height; pp.EnableAutoDepthStencil=true; pp.AutoDepthStencilFormat=D3DFMT_D16; pp.SwapEffect=D3DSWAPEFFECT_DISCARD; if(FAILED(d3d_object->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hwnd, VertexProcessing, &pp, &d3d_device))) return false; d3d_device->SetRenderState(D3DRS_LIGHTING, FALSE); d3d_device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);// d3d_device->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME); InitObj(); Init2DObj(); SetPerspective(); return true;}void InitObj(){ Vertex Triangle[] = { { -0.5f, -0.5f, 0.0f, D3DCOLOR_COLORVALUE(1,0,0,0)}, { 0.5f, -0.5f, 0.0f, D3DCOLOR_COLORVALUE(1,0,0,0)}, { 0.0f, 0.5f, 0.5f, D3DCOLOR_COLORVALUE(1,0,0,0)}, { 0.5f, -0.5f, 0.0f, D3DCOLOR_COLORVALUE(1,1,0,0)}, { 0.5f, -0.5f, 1.0f, D3DCOLOR_COLORVALUE(1,1,0,0)}, { 0.0f, 0.5f, 0.5f, D3DCOLOR_COLORVALUE(1,1,0,0)}, { -0.5f, -0.5f, 1.0f, D3DCOLOR_COLORVALUE(1,0,1,0)}, { 0.5f, -0.5f, 1.0f, D3DCOLOR_COLORVALUE(1,0,1,0)}, { 0.0f, 0.5f, 0.5f, D3DCOLOR_COLORVALUE(1,0,1,0)}, { -0.5f, -0.5f, 0.0f, D3DCOLOR_COLORVALUE(1,1,0,0)}, { -0.5f, -0.5f, 1.0f, D3DCOLOR_COLORVALUE(1,0,1,0)}, { 0.0f, 0.5f, 0.5f, D3DCOLOR_COLORVALUE(1,1,0,0)} }; d3d_device->CreateVertexBuffer( sizeof(Triangle), 0, D3DFVF_CUSTOME, D3DPOOL_DEFAULT, &VB_Triangle, NULL); Vertex *Vertices; VB_Triangle->Lock(0, sizeof(Triangle), (void**)&Vertices, 0); memcpy(Vertices,Triangle, sizeof(Triangle)); VB_Triangle->Unlock();}void Init2DObj(){ Vertex Quad[] = { { 0.0f , -20.0f , 0.0f, D3DCOLOR_COLORVALUE(1,0,0,0)}, { 0.0f , 0.0f, 0.0f, D3DCOLOR_COLORVALUE(1,0,0,0)}, { 20.0f, -20.0f, 0.0f, D3DCOLOR_COLORVALUE(1,0,0,0)}, { 20.0f, 0.0f, 0.0f, D3DCOLOR_COLORVALUE(1,0,0,0)} }; d3d_device->CreateVertexBuffer(sizeof(Quad), 0, D3DFVF_CUSTOME, D3DPOOL_DEFAULT, &VB_Quad, NULL); Vertex *Vertices; VB_Quad->Lock(0, sizeof(Quad), (void**)&Vertices, 0); memcpy(Vertices, Quad, sizeof(Quad)); VB_Quad->Unlock();}void SetRotation(){ D3DXMATRIXA16 World; D3DXMatrixRotationY(&World, angle); d3d_device->SetTransform(D3DTS_WORLD, &World); angle += 0.01f;}void SetCamera(){ D3DXMATRIXA16 View; D3DXVECTOR3 Eye(0.0f, 0.0f, -5.0f); D3DXVECTOR3 LookAt(0.0f, 0.0f, 0.0f); D3DXVECTOR3 Up(0.0f, 1.0f, 0.0f); D3DXMatrixLookAtLH(&View, &Eye, &LookAt, &Up); d3d_device->SetTransform(D3DTS_VIEW, &View);}void Set2DCamera(){ float X = 1; float Y = 1; D3DXMATRIXA16 matOrtho; D3DXMATRIXA16 matIdentity; D3DXMATRIXA16 World; //setup the orthogonal projection matrix and the default world/view D3DXMatrixOrthoLH(&matOrtho, Width,Height, 0.0f, 1.0f); D3DXMatrixIdentity(&matIdentity); d3d_device->SetTransform(D3DTS_PROJECTION, &matOrtho); d3d_device->SetTransform(D3DTS_VIEW, &matIdentity); D3DXMatrixTranslation(&World,X - ((float)Width/2.0f),((float)Height/2.0f) - Y,0); d3d_device->SetTransform( D3DTS_WORLD, &World); //make sure zbuffer is disable //d3d_device->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE); d3d_device->SetRenderState(D3DRS_LIGHTING, FALSE);}void SetPerspective(){ D3DXMATRIXA16 Projection;// D3DXMatrixPerspectiveFovLH(&Projection, 1.0f, 640/480, 0.0f, 500.0f); D3DXMatrixPerspectiveFovLH(&Projection, 45.0f, Width/Height, 0.0f, 500.0f); d3d_device->SetTransform(D3DTS_PROJECTION, &Projection);}void Render(){ d3d_device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_COLORVALUE(0,0,0,0), 1.0f, 0); d3d_device->BeginScene(); SetPerspective(); SetRotation(); SetCamera(); d3d_device->SetStreamSource(0, VB_Triangle, 0, sizeof(Vertex)); d3d_device->SetFVF(D3DFVF_CUSTOME); HRESULT HR; HR = d3d_device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 4); Set2DCamera(); d3d_device->SetStreamSource(0, VB_Quad, 0, sizeof(Vertex)); d3d_device->SetFVF(D3DFVF_CUSTOME); d3d_device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); d3d_device->EndScene(); d3d_device->Present(NULL, NULL, NULL, NULL);}void Kill3D(){ if(VB_Quad != NULL) { VB_Quad->Release(); VB_Quad = NULL; } if(VB_Triangle != NULL) { VB_Triangle ->Release(); VB_Triangle = NULL; } if(d3d_device != NULL) { d3d_device->Release(); d3d_device = NULL; } if(d3d_object != NULL) { d3d_object->Release(); d3d_object=NULL; }}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement