Jump to content
  • Advertisement
Sign in to follow this  
Reminator

Help on Drawing Lines in DirectX

This topic is 3497 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

Hi, I've been trying to draw a line as per one of the exercises in Introduction to 3D Game Programming w/ Direct X 9.0c, but I am having compiling errors. Here's the code: void HelloD3DApp::drawScene() { HR(gd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255, 255, 255), 1.0f, 0)); RECT formatRect; GetClientRect(mhMainWnd, &formatRect); HR(gd3dDevice->BeginScene()); mFont->DrawText(0, _T("Byaaaah!!!"), -1, &formatRect, DT_CENTER | DT_VCENTER, D3DCOLOR_XRGB(rand() % 256, rand() % 256, rand() % 256)); /////////////// line drawing D3DXVECTOR2 vLine[2]; ID3DXLINE *pLine; D3DXCreateLine(gD3DDevice, &pLine); vLine[0].x = 200; vLine[0].y = 300; vLine[1].x = 300; vLine[1].y = 400; pLine->Begin(); pLine->Draw(vLine, 2, D3DCOLOR_RGBA(100, 50, 100, 50)); pLine->End(); HR(gd3dDevice->EndScene()); HR(gd3dDevice->Present(0, 0, 0, 0)); } And here is the output: Compiling... cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release HelloDirect3D.cpp c:\users\remington\rem's games\game development\game.design.ebooks.pack\programming\introduction to 3d game programming with directx 9.0c shader approach\part ii\chapter 4\hello direct3d\hellodirect3d.cpp(66) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. c:\program files\microsoft visual studio 9.0\vc\include\string.h(74) : see declaration of 'strcpy' c:\users\remington\rem's games\game development\game.design.ebooks.pack\programming\introduction to 3d game programming with directx 9.0c shader approach\part ii\chapter 4\hello direct3d\hellodirect3d.cpp(111) : error C2065: 'ID3DXLINE' : undeclared identifier c:\users\remington\rem's games\game development\game.design.ebooks.pack\programming\introduction to 3d game programming with directx 9.0c shader approach\part ii\chapter 4\hello direct3d\hellodirect3d.cpp(111) : error C2065: 'pLine' : undeclared identifier c:\users\remington\rem's games\game development\game.design.ebooks.pack\programming\introduction to 3d game programming with directx 9.0c shader approach\part ii\chapter 4\hello direct3d\hellodirect3d.cpp(113) : error C2065: 'gD3DDevice' : undeclared identifier c:\users\remington\rem's games\game development\game.design.ebooks.pack\programming\introduction to 3d game programming with directx 9.0c shader approach\part ii\chapter 4\hello direct3d\hellodirect3d.cpp(113) : error C2065: 'pLine' : undeclared identifier c:\users\remington\rem's games\game development\game.design.ebooks.pack\programming\introduction to 3d game programming with directx 9.0c shader approach\part ii\chapter 4\hello direct3d\hellodirect3d.cpp(120) : error C2065: 'pLine' : undeclared identifier c:\users\remington\rem's games\game development\game.design.ebooks.pack\programming\introduction to 3d game programming with directx 9.0c shader approach\part ii\chapter 4\hello direct3d\hellodirect3d.cpp(120) : error C2227: left of '->Begin' must point to class/struct/union/generic type type is ''unknown-type'' c:\users\remington\rem's games\game development\game.design.ebooks.pack\programming\introduction to 3d game programming with directx 9.0c shader approach\part ii\chapter 4\hello direct3d\hellodirect3d.cpp(121) : error C2065: 'pLine' : undeclared identifier c:\users\remington\rem's games\game development\game.design.ebooks.pack\programming\introduction to 3d game programming with directx 9.0c shader approach\part ii\chapter 4\hello direct3d\hellodirect3d.cpp(121) : error C2227: left of '->Draw' must point to class/struct/union/generic type type is ''unknown-type'' c:\users\remington\rem's games\game development\game.design.ebooks.pack\programming\introduction to 3d game programming with directx 9.0c shader approach\part ii\chapter 4\hello direct3d\hellodirect3d.cpp(122) : error C2065: 'pLine' : undeclared identifier c:\users\remington\rem's games\game development\game.design.ebooks.pack\programming\introduction to 3d game programming with directx 9.0c shader approach\part ii\chapter 4\hello direct3d\hellodirect3d.cpp(122) : error C2227: left of '->End' must point to class/struct/union/generic type type is ''unknown-type'' At first I thought is was because I didn't declare D3dx9core.h in my header, but I did and it still came up with that output. Any input would be much appreciated. Thank you in advance.

Share this post


Link to post
Share on other sites
Advertisement
Cool, it works now. Thanks! But I have another problem. Whenever I try to resize the window an error window pops up and says an "unexpected error occurred."

My code is:

void HelloD3DApp::drawScene()
{
HR(gd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255, 255, 255), 1.0f, 0));

RECT formatRect;
GetClientRect(mhMainWnd, &formatRect);

HR(gd3dDevice->BeginScene());

mFont->DrawText(0, _T("Byaaaah!!!"), -1,
&formatRect, DT_CENTER | DT_VCENTER,
D3DCOLOR_XRGB(rand() % 256, rand() % 256, rand() % 256));

/////////////// line drawing
D3DXVECTOR2 vLine[2];
ID3DXLine *pLine;

D3DXCreateLine(gd3dDevice, &pLine);

vLine[0].x = 200;
vLine[0].y = 300;
vLine[1].x = 300;
vLine[1].y = 400;

pLine->Begin();
pLine->Draw(vLine, 2, D3DCOLOR_RGBA(100, 50, 100, 50));
pLine->End();

HR(gd3dDevice->EndScene());
HR(gd3dDevice->Present(0, 0, 0, 0));
}


I'm guessing it may be the fact that I don't have OnLostDevice anywhere...

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!