Kesper Posted February 5, 2003 Posted February 5, 2003 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 Quote
*Experts* Nerseus Posted February 5, 2003 *Experts* Posted February 5, 2003 You can use GDI to draw onto surfaces fairly easily. For example (taken from the DX9 wizard generated code, mostly): 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 Quote "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
shouzama Posted February 5, 2003 Posted February 5, 2003 (edited) 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... :eek: EDIT: Wrong forum, anyway :P Edited February 5, 2003 by shouzama Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.