Sign in to follow this  
ManixReaper

DirectX 9 - Drawing a line

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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??

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this