SDL or windows.h

Started by
3 comments, last by kop0113 8 years, 2 months ago

Hi, is windows.h required in order to make a directx application?

This is my first question I ever asked on a game programming forum BTW.

Thanks in advance.

Advertisement

You asked the question in a way that leads to a more nuanced answer than you probably wanted.

The short answer is "yes and no."

The long answer is that you can't make a Windows application without using the Windows SDK and API in some fashion. In particular, Direct3D is part of the Windows SDK and depends on some Windows API basic types. And you also need to use the Windows API to create an actual window, et cetera.

However, you can make one without you yourself manually including the Windows.h header. You can use libraries like SDL or whatnot to create windows and manage all of that, and other APIs that wrap direct use of Direct3D, et cetera. Or you can write a game using just the C++ standard input and output stuff (in a console window) and let the C++ runtime create your console window for you, et cetera.

If you're just getting started and you've already moved on from creating simple text-based games, SDL is a good way to go.

It's been a while since I was slinging C++, but I seem to recall that SDL (1.2) worked pretty nicely as a simple window management and input library to paper over the uglier ways you do that in raw Win32 code. For initializing DirectX, or binding an OpenGL context, all you really need is the HWND of your main window to bind to, which SDL exposes.

Eric Richards

SlimDX tutorials - http://www.richardssoftware.net/

Twitter - @EricRichards22

Thank you all I have my answers that really helped.

I have made simple projects in Unity3D, and C++ however I am more interested in graphics programming so as I am writing this I am actively teaching myself the basic concepts of Direct X. I am also looking at OpenGL However I prefer D3d because I have found more documentation for it than OpenGL.

Also sorry for the late reply.

Thanks Again.

Slightly late to the party but it might help.

In OpenGL, often people starting out (and for those who try to keep dependencies down) use GLUT (OpenGL Utility Toolkit) which provides the bare minimum for Windows creation (http://freeglut.sourceforge.net/) FreeGLUT is the more modern version of GLUT.

In DirectX, there has been made similar called DXUT. It used to be provided with the DirectX SDK but has now also been separated into a separate library (https://github.com/Microsoft/DXUT). This library will help you avoid dealing quite so much with the (admittedly archaic) Win32 API. Obviously because DirectX has limited platform support, the value of a toolkit like GLUT is perhaps reduced, but still handy nonetheless.

You can actually avoid most of the Windows API by using the Windows 8.1/10 store framework (and using C++/cx). I don't really suggest it because I don't think this technology is going to be supported for very long but it is still something you might be interested in knowing about. An overview: https://msdn.microsoft.com/en-us/magazine/jj991975.aspx

Also, if you did ever decide to go back to OpenGL (and if you are interested in graphics programming you will likely end up learning and using both), I find this a great place to start for documentation (http://openglbook.com/chapter-1-getting-started.html)

http://tinyurl.com/shewonyay - Thanks so much for those who voted on my GF's Competition Cosplay Entry for Cosplayzine. She won! I owe you all beers :)

Mutiny - Open-source C++ Unity re-implementation.
Defile of Eden 2 - FreeBSD and OpenBSD binaries of our latest game.

This topic is closed to new replies.

Advertisement