DirectX 9 - Drawing a line

Started by
8 comments, last by ManixReaper 18 years, 8 months ago
Well for a while now I have been making a small tetris game. I now have all the code that actually runs the game and want to implement a GUI for it using DirectX 9 (I have used GDI before so want to move on). Problem is I cannot draw even a line to get started!!! I want to do it all in 2D just straight on the screen but I cannot find any information on the web to help. Have looked at DrawPrimitive and Line Lists but nothing seems to make sence/work. Any links or help would be appreciated.
Advertisement
You could use ID3DXLine but it's kind of in an odd state. If it's just tetris it ought to work ought.

I was wondering if this could be used for a tether, as in a rope between a point from a block to a point on a ball. Kind of like for something swinging from a tree branch...
In my last project, a topdown space sim, I was using ID3DXLine to draw a line between the ship's location and its autopilot target. Worked fine for me. Also very useful for drawing things like triangles, squares, grids etc that you want to change on the fly (zooming in to a specific region of a map, for example). It has a Draw3D function for 3D space transformations, or you can just use Draw for simple X/Y in screen coords.

As far as the tether, it will be okay if you just want a straight line between the two objects. You'll have to do some serious math and vector plotting if you want the tether to 'bend' with visual drag between the two items (like a string attached to a flying kite or a fishing line etc).
Why not simply use the D3DPT_LINELIST (or D3DPT_LINESTRIP) type with DrawPrimitive?

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Thanks for the advice. Have tried using ID3DXLine but it didn't want to work for me. I might go back and have another look. Thanks again.

BTW, these line wont move so they are just a set of predefined co-ordinates
First of all, thanks for everyones help. I managed to get it working in Visual Studio. I now have lines ;-) Now I've run into a problem with Dev-C++. I can get DirectX to work using d3d9.h, but I cannot find the proper d3dx9core equivalent in the Dev-c++/lib directory. Has anybody had this problem aswell??
I have it!

After a couple of days chasing my tail, I have figured out what was wrong. When you download Dev-C++ you get some BASIC DirectX stuff. To get everything that you need to program DirectX in Dev-C++ you have to download the proper package.

http://www.devlib-central.org/mambo/index.php?option=com_remository&Itemid=12&func=fileinfo&filecatid=5&parent=category

Once downloaded, install and Bobs your uncle, it works.

I probably look really dumb right about now!
Why use Dev-C++ when you can use Visual Studio? VS is a much more complete IDE and seems to be the standard for almost any development environment.
Rob Loach [Website] [Projects] [Contact]
It is good to get experience in more than one IDE. I find that Dev-C++ give me a better understanding of what is going on and how C++ works. Next project I do will be in VS.

This topic is closed to new replies.

Advertisement