Direct3D11 Initialization for 2D Game

Started by
2 comments, last by KingofNoobs 11 years, 6 months ago
Hello,

This is my first post on this forum. I am following along with Frank Luna's DirectX 11 book, and am also using the Rastertek tutorial online for learning how to initialize a 2D system in Direct3D. To be honest, I thought the whole thing would be a lot easier than it is, but basically I have got a lot of 3D stuff working in "my" engine, but I fell flat on my face when I tried to implement 2D. I did load up a bitmap into the engine generated by Rastertek, but that is not much of an achievement.

I have attached my solution for your perusal. I have cleared the screen with Pink so it is very obvious when something is not rendering. Well, nothing is rendering. I have stepped through my program, then the working rastertek program maybe 100 times. I know there are differences, i.e. I am using the effects framework to set pixel and vertex shaders, and I am using somewhat complex pixel and vertex shaders where the rastertek program uses more simple ones. I did this because I hope for my engine to eventually be switchable from 2D to 3D simply by using different inherited classes, i.e. App2D and App3D inherited from ApplciationLayer, and toggling a few settings to make the switch.

If I can't get this to work in the next 24 hours, I'm going to scrap this simple engine and start over, hopefully in less time, and hopefully with a better result, but if any of you would be kind enough to build the code (on V++ 2010) and see what you get, I would be greatly appreciative. Also, if anyone can offer some good debugging advice above and beyond google it, ask in this forum, check tutorials, check variable values in the debugger, and think, I would be greatly appreciative.

Again, thank you all for your kind help, and I look forward to my time with this forum in the future.

Regards,

Dave Ottley

I wonder as I wander...

http://www.davesgameoflife.com

Advertisement
So I somewhat get the feeling this is a gross over complication of a switch between 2D and 3D. Generally if you want to draw in 2D vs 3D, you simply change your projection matrix to flatten the scene, you shouldn't really have to change your entire engine. Try researching the differences between Perspective Projection and Orthogonal Projection matrices.

As far as debugging goes, use the tool PIX in your SDK, it's the greatest tool you have when rendering.

And as a general rule of thumb as a programmer, if you're really stuck trying to figure out what's going on, then that's more reason to *NOT* throw away your project. This is how you get better at debugging, keep searching for the bug. Try and guess what is going wrong and test that hypothesis, use PIX, any number of things. But most of all, don't give up, just keep looking.

Good luck, and don't get despirited!
Perception is when one imagination clashes with another
Seabolt,

Thank you for the good advice. I will look into PIX. I fully agree with you that I have gotten too complicated in my engine by trying to mix some fairly advanced 3D rendering techniques that I was working on with 2D. I feel like using the FX framework and lighting and so on has made the bug harder to find so I'm just rebuilding another, simpler engine today and will see if I get the same bug. If not, I think I'll go back and try to figure out what happened on the more advanced version of the engine, but if the same bug comes up on the simple 2D only version, then I'll start debugging from there.

Thanks for the encouragement and I will press on, press on!

:D

-Dave Ottley

I wonder as I wander...

http://www.davesgameoflife.com

If anybody wants to build the solution posted above and let me know what they think, I would be greatly appreciative. :D

I wonder as I wander...

http://www.davesgameoflife.com

This topic is closed to new replies.

Advertisement