graphics programming with C++

Started by
26 comments, last by Servant of the Lord 8 years, 11 months ago

But I don't want to do something like sfml apart from the pain in setting it up even though it makes thing easier I don't just want to make games it is more like I want to know how things work. So when I start I will start with some low level api.


Sometimes it helps to use the middle-level APIs, to learn how their interfaces are designed, before jumping to a low level and not knowing what to aim for.

But if that's really what you want to do, my advise would be to use Qt. It provides low level access to mid-level libraries in a cross-platform way, and you'll learn how GUI widgets fit together.
Qt is more for desktop applications rather than games, but it sounds like that's what you are interested in.

If you are interested in low-level 3D or 2D graphics, then you *should* use SFML for managing your windows and events, and use OpenGL for the graphics... but I think that'd dive you too fast into the deep end.

Perhaps a more ideal choice is for you to use SDL, which is probably low enough to satisfy you. I'd suggest starting with SDL, and after a year of using it, decide how you want to proceed from there.
Thanks for the advice , I will try to use SDL first but I don't think that high level apis really help , how does learning wpf/winRT help you in learning win32 api? But it may help me in this case.
Advertisement

Thanks for the advice , I will try to use SDL first but I don't think that high level apis really help , how does learning wpf/winRT help you in learning win32 api? But it may help me in this case.

A better question is why you think you would need to learn Win32 at all. Because it feels more manly to use an API that has been bloated with 20 years of backward compatibility? wink.png (I've been there myself. "Real" programmers must use X, because X looks complicated! laugh.png)

(I'm not bashing Win32 - I'm bashing projects that use Win32 when they don't actually need to. Some do need to. Win32 is an amazing work of engineering talent - under very adverse circumstances)

Programmers go low level when they need low level, and go high level when they need high. You go to the levels your project needs, and you learn the APIs your project needs, when your project needs it. If I'm making a complex desktop application, I can use Qt and I don't even need to touch Win32 except in the very rare parts of my project that actually need it. A single project can use 99.9% higher level APIs, and still go low-level APIs for the 0.1% when it's required. This makes things easier to develop, easier to maintain, and easier to expand.

Note: By "high level" and "low level" I mean "higher than Win32, but still not overly abstract", and by "low level" I mean "Win32".

You can go even lower level than Win32, but just because you can doesn't mean you should - unless a part of your project requires it.

Qt is not exactly a low level API, but it is higher than pure Win32.

SDL is not a high level API. It's low level, but it is a higher level than pure Win32 or using OpenGL for 2D.

What is your current goal for your current project? Which APIs does your project need? Use those ones.

Are you doing 2D or 3D? Are you making a game or an application? For what platform?

My own project uses 80% Qt, 10% SFML, and 10% OpenGL - and a bunch of other small libraries besides. It also uses 0.000001% Win32, where the project needed to make four function calls that Qt didn't expose. Four Win32 function calls - in a project with hundreds of classes and thousands of functions. smile.png

Not only do different parts of a project need different APIs - different parts of a project need different levels of abstraction. In any large project, you'll find custom low level code, and custom high level code, of various levels - three or four or more levels of abstraction. Programming is built up of layers of abstraction. Even using Win32 is multiple levels of abstraction above what's actually running on the CPU.

When I write custom, pure-C++ code not even using any other APIs, I'm still writing in various levels of abstraction - two or three.

High level does not equate to easier. It means you have a lot more learning curve specific to the tools you use. Qt has got some issues for making a game for example. You can do it that way but I don't think it saves you much effort and it has a cost. But if other people know Qt then it is a big advantage that you can all work on the codebase.

This is my thread. There are many threads like it, but this one is mine.

A better question is why you think you would need to learn Win32 at all.

I agree fully.
A good programmer does not want to reinvent any wheels unnecessarily. Therefore it makes good sense to use third-party libraries of good quality.
I am also using Qt, but I would use POCO instead if my current project wasn't user-interface centered.
Or perhaps a leaner UI library if my project only calls for window/widget management.
Win32 was cool 10 years ago; we have moved on. There are better ways. Even WTL. smile.png
A better use of resources would be to program a bit in assembly code. (And then stop using it) That will teach you useful things about registers and memory management that will help you out in day to day C++ programming.

It doesn't hurt having knowledge of win32 programming, but you won't be writing any 98% of the time, provided you are mainly a Windows programming guy.

Too many projects; too much time

Qt has got some issues for making a game for example. You can do it that way but I don't think it saves you much effort and it has a cost. But if other people know Qt then it is a big advantage that you can all work on the codebase.

Yes, Qt is pretty terrible for games (though the newer QML stuff might be better, I don't have experience with QML). My specific project is a desktop application (my game's editor), which Qt is well suited for. For complex desktop applications, it might be better to use Qt or another GUI library than to use Win32 [if you are coding in C++] - unless your application needs it. For 2D games, it might be better to use SFML over OpenGL - unless your game needs it. And don't use performance as a "need", until you've actually profiled your game and find SFML insufficiently fast or lacking in some needed feature.

You're right about Qt being bad for games - thanks for mentioning that, that could've caused some confusion. smile.png

OP - have you heard of handmade hero?

https://handmadehero.org/

This guy is a very talented and experienced programmer and goes through game creation with no external libraries at all - it is aimed at those of us who are curious about what sorts of "magic" are happening behind the scenes at the low level

Well you can use higher level tools to make games or lower level , you won't be competing against AAA titles whatever you do . The only thing you gain is knowledge and by using lower level APIs you learn more that is what it's all about for me . Even if you learn high level first for the 0.01% you still need to learn low level APIs then why not do it first.
The project I have in my mind is a game engine , it is reinventing the wheel and even won't compete against the ones that already exist but that is what I want to do maybe I can or I cannot but still worth a try.

Best of luck on your programming journey.

This topic is closed to new replies.

Advertisement