DirectX Paint Program

Started by
9 comments, last by Jettoz 17 years, 4 months ago
Hello everybody, This is my first post here. Although I've semi-understood a good many of the loops I have to jump through to setup Windows, DirectX and some basic functionality of both, I want to expand into some higher learning in DirectX's direction, but I'm not sure how. First of all, I want to describe the best I can what I'm looking to be able to do. I figured I could start off by having Windows and DirectX interact with a paint program. First, a simple paint program (two buttons for different colors or something), being able to paint circles onto a fixed-width image, and hitting a button to save the image to formats like JPG, TGA, PNG, etc. Then from there, I want to move on to variable size images (maybe up to 40 inches across and tall @ 72 dpi ... er, 2880x2880 or higher) with working image scrolling and saving the entire image. Then I want to create a multilayered version that can save movable pieces above the painted image, like placing chairs, tables, rugs, etc (only visual, no collision or special properties) and saving that out as an image. Basicly, building up a tile / map editor, except that I don't want to use square tiles, so much as I want to paint with the tiles (masked/alpha PNGs in most cases, to produce non-square results, in a freehand fashion). So first question is, will DirectX handle large dynamic image creation and saving, and if so, how does one do about creating a dynamic (but savable) DirectX image/buffer/surface? Any advice or linkage/direction would be muchly appreciate. Thanks in advance! -Tyler
P.S. - This is what the alphabet would look like if Q and R were eliminated.
Advertisement
Check out www.planetsourcecode.com under C++ there are a ton of open source paint programs to learn from.
____________________VB/C++/C# Programmer
Thanks for the heads up! That's a wonderful site! I got basic line painting now, I just gotta figure out how to mingle the alpha-ed pngs and the painting process :) I'll dig through the site some more and see if I can do it the GDI or if I have to kick the tires and light the DirectX fires. Any recommendations for that?
P.S. - This is what the alphabet would look like if Q and R were eliminated.
I'll check around for some C++ code in the morning and post some links on paint programs that should help you some more. Just remember when you view open source code to keep in mind that their code may work but could be sloppy or teach bad habits. However this isn't true with all code, just some code out there. I personally use open source programs just as a reference of how to make what I need or how a function is used. Check back in 15 hours or so, I should have some links here for you. I hope your program is working out good.
____________________VB/C++/C# Programmer
Thank you, again! I often wonder why good-practice programming isn't more widely taught, and/or available for examination. My biggest problem right now with programming (in genearl) is that everybody seems to do most of it a different way, and everyone thinks that there's is the best, and they all appear to work ... I just wish that it was more clean-cut, as opposed to having five million ways to successfully create a window you can draw on that are correct but more of less useless (and most ineffecient, or worse). Is there a book of standard/good practice for C++ / Windows API / DirectX? or do they always leave it so open ended?
P.S. - This is what the alphabet would look like if Q and R were eliminated.
Hello again, I found some links and just a notice I have no tested these programs or looked into the source code so I have no idea if they will be of any help to you. I did pick the best things I could fine on my own judgment, however some of these are made for DOS, they should teach you the concepts though to get the same effect in WIN32 programming. Sorry that I couldn’t find more links or a tutorial, I’ve been very busy with a project lately.

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4600&lngWId=3
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=2007&lngWId=3&txtForceRefresh=1128200617201234472
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=3482&lngWId=3
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=291&lngWId=3
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=6282&lngWId=3
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=7938&lngWId=3
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=2084&lngWId=3
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=5676&lngWId=3
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1600&lngWId=3
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=819&lngWId=3
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=9775&lngWId=3
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=3099&lngWId=3
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=3162&lngWId=3

If I find anything else I'll post some more links, hope this helps!
____________________VB/C++/C# Programmer
You've been awesome help! I really appreciate all the good leads. Good luck with your projects, and I'll peruse these links and see what I can come up with. Thank you again!

-Tyler
P.S. - This is what the alphabet would look like if Q and R were eliminated.
Quote:Original post by TogaMario
Thank you, again! I often wonder why good-practice programming isn't more widely taught, and/or available for examination. My biggest problem right now with programming (in genearl) is that everybody seems to do most of it a different way, and everyone thinks that there's is the best, and they all appear to work ... I just wish that it was more clean-cut, as opposed to having five million ways to successfully create a window you can draw on that are correct but more of less useless (and most ineffecient, or worse). Is there a book of standard/good practice for C++ / Windows API / DirectX? or do they always leave it so open ended?


That's why programming is sometimes called an art and not a true science!
Anyways you don't really need to use DirectX to do what you are planning and if look at all this source code for a paint program written in C# doesn't intimidate you then go ahead since writing it in DirectX instead of GDI+ will probably 2x the code!
Personally I'm just started on my own personal paint program written in VB and it has a long way to go but Paint.net has given me some good ideas.

[size="2"]Don't talk about writing games, don't write design docs, don't spend your time on web boards. Sit in your house write 20 games when you complete them you will either want to do it the rest of your life or not * Andre Lamothe
I've got Direct3D setup with sprites bouncing around the screen, and rotating gleefully. I even got a RenderToSurface setup going that offsets the sprites a bit, renders them to a texture, and displays that on screen. Now all that's left to do is figure out how to stop it from clearing itself, AND not look jacked up every time I start the program :P Since that pretty much destroys any image data that it should store (and commenting out the "Clear" method will cause a corrupt image / and not starting with a fresh blank slate when the program starts). I'll be adding the "only draw to the surface when mouse is down" functionality pretty soon, but I still don't know how to retain drawn data with reliability. Any advice?
P.S. - This is what the alphabet would look like if Q and R were eliminated.
Ended up figuring out that the DirectX RenderToSurface setup I had required me to keep the AutoStencilDepth setup in PresentParams and also to match the DepthFormat of the RTS that I was using. All is well, and it works beautifully so far!
P.S. - This is what the alphabet would look like if Q and R were eliminated.

This topic is closed to new replies.

Advertisement