DirectX Topics include: Managed DirectX (DX9)

Go Back  Xtreme .NET Talk > .NET > Graphics and Multimedia > DirectX > D3d Drawing 2d objects


Reply
 
Thread Tools Display Modes
  #1  
Old 02-04-2003, 08:29 PM
Kesper Kesper is offline
Newcomer

Preferred language:
vb.net
 
Join Date: Feb 2003
Location: Washington State
Posts: 4
Kesper is on a distinguished road
Default D3d Drawing 2d objects

I am working on the GUI part of my engine and notice that there are samples on drawing text to the screen in 2d (and even makeing the text 3d) But I can't figure out how to draw simple shapes like rectangles, triangles, circles...etc.

What I would realy like to know is how to use gdi+ to create a shape and d3d9 to draw it to the screen. Anyone know how this is done? I am useing VB.net and DX9.

Kesper
Reply With Quote
  #2  
Old 02-04-2003, 10:39 PM
Nerseus's Avatar
Nerseus Nerseus is offline
Danner

Preferred language:
C#
 
Join Date: Oct 2002
Location: Arizona, USA
Posts: 2,547
Nerseus is on a distinguished road
Default

You can use GDI to draw onto surfaces fairly easily.
For example (taken from the DX9 wizard generated code, mostly):
Code:
Bitmap bmp = new Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp);
// Do your drawing on g ...

Texture texture = Texture.FromBitmap(device, bmp, 0, Pool.Managed);

Most non-circular shapes can be drawn in Direct3D by breaking your shape into triangles. Obviously, squares and rectangles are the easiest (next to triangles ). A hexagon or a more "random" object might be slightly harder. If it's convex, you could use a simple Triangle Fan. Don't forget Direct3D can draw lines as well - just use LineList instead of TriangleList.

For circles, arcs, bezier curves and such you might actually do well to use GDI. I can't speak of the performance as I've never really tried generating objects and loading surfaces per-frame. If you're not worried about the framerate and only need to generate the shapes once to prepare a surface there shouldn't be any problem.

-nerseus
__________________
"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Reply With Quote
  #3  
Old 02-05-2003, 01:56 AM
shouzama shouzama is offline
Freshman

Preferred language:
VB.NET
 
Join Date: Jan 2003
Location: Another World
Posts: 38
shouzama is on a distinguished road
Default

Quote:
Originally posted by Nerseus
You can use GDI to draw onto surfaces fairly easily.
You know what, I never thought it was possible, even if it was before my eyes...

EDIT: Wrong forum, anyway :P

Last edited by shouzama; 02-05-2003 at 02:03 AM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Drawing objects theHollow DirectX 1 01-12-2005 03:36 PM
Examples of 2d in D3D Classes Mykre DirectX 31 09-28-2004 05:11 PM
screenshots in d3d ThePentiumGuy DirectX 5 03-12-2004 09:13 PM
SpriteFlags in D3D (C#) woodsman DirectX 6 02-24-2004 06:34 AM
D3D Camera Chamma DirectX 2 09-24-2003 07:35 AM

Advertisement:

Powered by liquidweb