Re: Architecting and programming a graphics engine in C++ & OpenGL
Rémi Papillié <[email protected]> Fri, 18 Mar 2011 14:58:05 +0100
| Newsgroups | gmane.games.devel.sweng |
|---|---|
| Message-ID | <[email protected]> |
Hi Tommy, While this might not answer completely such a broad question, I would recommend you look at this site: http://gamearchitect.net/ More specifically, some articles called 'An Anatomy of Despair' explain the design of the author's engine. See for instance: http://gamearchitect.net/2008/04/19/an-anatomy-of-despair-orthogonal-views I would also recommend the excellent book 'Game Engine Architecture', by Jason Gregory. Note, however, that these resources are mainly oriented towards game engines as whole. AFAIK, there are not many resources on the specifics of graphics engine design and architecture but, as you said, mainly a lot of very technical articles one some technologies and implementations. For what it's worth, here is the structure I currently use on my personal engine. It works, but has not been confronted to a real prod, so what follows is definitely not bullet-proof. The technical API (OpenGL/DirectX) is abstracted away in a thin layer. I use this layer mainly for readibility purposes (e.g being able to write texture->enableFiltering(BILINEAR) instead of two or three cryptic OGL/DX calls), but with a bit more work, you can also use it to make the engine cross-api (with many simple but error-prone details, such as matrix transpositions). On top of that, two modules are present: - The graphics scene contains an abstract description of graphical elements that are part of the world. No shading algorithms here, just plain buffers augmented with various information (transforms...). The scene handles all issues about traversal and culling. Whenever a render is asked, a render list is built by querying the spatial partitioning structure, and then sent to the renderer (see below). - The renderer is just the raw implementation of shading algorithms. It receives a render list + a frustum and draws everything, using various techniques (e.g forward or deferred shading). The render list basically contains packets in the form <transform, mesh, material> (+ lights), but this is highly dependent on how the rest is implemented. Hope this helps! I'll also be very happy to learn about other ways of designing graphics engines, if someone else has good resources on the subject ;) Rémi 2011/3/18 Tommy Brett <[email protected]>: > Hi folks, > I've been working as an AS3 programmer / animator for the last 3.5 years, > and have the strongest desire to leave the marketing industry behind and > pursue my original intended career as a games programmer, which I sidelined > due to a very coincidental series of events. To this end, I've been (slowly) > building a graphics engine using C++, OpenGL and nVidia CG which renders > very large chunks of terrain using GPU Clipmaps. The idea is that eventually > it will render planets with atmosphere and real time shadows, or die trying, > and in any case will serve as my main portfolio piece when I eventually > start applying for positions. Because I've been outside of my programming > comfort zone for so long it's been slow going, but now that I've finally got > a firm grasp on shaders and the OpenGL pipeline it's time to look to the > future. > This is where my problem lies; although there are many examples on the 'net > showing me how to animate the most beautiful normal mapped cobbled cube, or > tutorials on specific rendering / culling / lighting algorithms, I've yet to > find a resource beside Michael Abrash's Graphics Programming Black Book > (which sits on my desk, reminding me of what I should have been doing all > along) which goes into the subject of writing a graphics engine. See > although I can write perfectly passable C++, and thanks to my AS3 > programming experience which has frequently required that I get my projects > right 'the first time', I'm fairly adept at planning and designing my > classes before I begin... But from a C++ standpoint, I'm somewhat in the > dark. What are the best practices for building a graphics engine in C++? > Exactly how OOP should I go? How should I handle the use of multiple shaders > on chunks of geometry? There's just this giant multitude of questions, and > although I have a knack for over engineering things, I really want to have a > better picture of what I'm aiming for before I start, or I'll end up with > the monstrosity that is my terrain prototype (it runs, but it's so, so > ugly). > Currently my idea for a graphics engine involves something like an engine > class that takes render packets of data, has some sort of ability to sort > them into an order that best facilitates speedy rendering, and changes its > state depending on the information in the packets. E.g. one packet might be > a chunk of terrain, and could include information about what shaders to use, > how to determine its potential visible set, and the type of collision > detection to use (though this deviates a little from the graphics engine > part). There might be an arbitrary number of terrain packets, followed by > some character models or buildings using a different type of culling > algorithm. My worry aside from the obvious problem of the whole idea > possibly being crap, is that it's too general. How could I possibly create > an engine that handles every possible rendering type, shouldn't I perhaps > start with the assertion that I'm building a terrain engine, and base > everything around rendering sphere like chunks of geometry with varying > levels of detail? But on the same token, I don't just want to end up with > another terrain engine prototype as seen on youtube(tm). > So I suppose what I'm looking for are book suggestions, or perhaps > open-sourced graphics engines that I could look at and learn from, or maybe > I should just try and get a position as a junior-something-programmer and > learn by doing (the trouble is there aren't any such positions available > where I live, and relocation would be difficult to justify based upon the > possibly low salary expectations of a junior position, I'd like at least > some leverage). Ideas? Suggestions? Is this even the right place to ask such > broad questions? I'm all ears. > - Tommy > _______________________________________________ > Sweng-Gamedev mailing list > [email protected] > http://lists.midnightryder.com/listinfo.cgi/sweng-gamedev-midnightryder.com > > _______________________________________________ Sweng-Gamedev mailing list [email protected] http://lists.midnightryder.com/listinfo.cgi/sweng-gamedev-midnightryder.com