Irritated with Nvidia Demos

I’m sure others are guilty as well, but right now I’m frustrated with the lack of organization in an Nvidia bump mapping demo.

All the code is written pretty well in C and it’s easy to understand. But all the code is in ONE 3000 line file. Everything from matrix operations to loading tgas is in ONE big file. I already know how to add matrices. I don’t need to see that code. What I would really like to see is all the bump mapping code in one small file. And all that other crap in separate files.

Maybe I am just not an uber programmer yet. But I thought having everything (including the kitchen sink) in one file was bad programming–especially for a demo meant to teach. What do you all of you think about this?

I think you’re right. The demos, quite frankly, are horrible. Sure they work but my god they make my eyes bleed just looking at it. Now since I have been studying their demos for quite a long time now, I can get through them better than before but they still could be better, much better. Also more comments would help too. I think one of the problems is that they rely too much on all of their libraries (which are not fun to read or look at either). Also like you say, everything gets jammed into one huge arse file. Now I’m not trying to say anything bad about the programmers, but I do feel that nvidia should make a better effort to make the demos nicer to read and understand.


I think your right. I dont speak for everyone else, but I think the general concensus is that many of the Nvidia demos are ill organized. Its frustrating at first to make sense of the code. What I like to do is go through and delete everything that is of no relevance to what a particular demo is trying to demonstrate. Helps allot.

Old GLman

Oh also, more meaningful identifiers would help a lot. I have also noticed that sometimes the way some things are done are a waste and a bit redundant. Kind of like this:

void do_something( void )
blah blah
blah some more

void do_the_action( void )

Then in the program do_the_action is called. Now what the hell is the point of that? Can’t we just call do_something directly and be done with it? Surely doing this kind of thing too much isn’t good performance wise.

OT: I just got finished with a very hard test so that’s why I may seem a bit gripey right now if any one wonders.


just to be contrary, i prefer having all the code in one(or a couple of) files like the older nvidia demos,
i m not really a fan of the newer ones which rely on outside libraryes

yeah, i’m with zed. the new ones force you often to use some complicated tree and library structure…

well, what i love is smalle exes. no complex models, no complex stuff, just small and utterly ugly, showing one purpose…

i think, in the end, the way humus codes is a sweet way. short clean and even quite good looking

i remember the old simple glut demos from nvidia… small and clean…

today nutty codes that style (thought with its own library, dunno really why, but he wants to ), and his demos are at least very good readable…

Yep I disagree with the original post too.

Simple examples, no “framework” thanks. If I want your framework I’ll give it to you.

3000 lines is not too large for a single module demo.

No complex libraries or baroque runtime infrastructure required either.

I don’t complain though, these guys are constantly putting up free training and simple explanations of complex subjects. Don’t kick a gift horse in the teeth.

I don’t see how you guys can view 3000 lines of code as “simple” but 5 files are a “complex infrastructure”.

I don’t think I’m “kicking a gift horse in the teeth”. NVidia is in the business of selling cards. Cleaner demos might help convince developers to use NVidia’s wonderful technology. And in the end, NVidia would sell more cards.

NVidia is a terrific company, but I think I could learn more from them if some of their code was more modular.

I use a contained library so I can get a very small main demo that basically says…




without any messy windows crap in the way. Very clean and very minimalist… I thought it the best way to go. Having small well documented files is the nicest way to present code.

Originally posted by Nutty:
without any messy windows crap in the way. Very clean and very minimalist… I thought it the best way to go. Having small well documented files is the nicest way to present code.


I like the simplicity of Nutty’s demos too. From his demos I was able to get per pixel lighting and stuff running quicker b/c of that. I don’t think im kicking any kind of horse in the teeth, ass, scrotum or anything else. I’m just trying to give suggestions to make the code easier to learn from. Because I remember I had a very hard time with the nvidia demos at one point and darn near every other person I see now is the same way. But untill they reach a point like I have where I have seen the demos for so long that I can now figure out what is going on a lot quicker and easier that I would have otherwise. With that said though I feel I need to say that I am very greatfull for all that nvidia does for its customers. The amount of demos, papers, presentations, etc is a lot and it’s a gold mine of info.

Oh also I do like the glh stuff though, it makes setting up extensions, for example, a lot easier and quicker than to write all that stuff myself.

You know what I think would be cool? Is for nvidia to like have a small team or something to write…like nehe style tutorials to go along with their demos explaining all that is going on. Like the math, theory, etc. I think that would be a great addition to the dev site and would help people trying to learn 3d gfx programming or trying to get more advanced (like me ) quicker and with less pain.


Yep, I like your minimalist approach too Nutty. There are frameworks and then there are err… frameworks from hell.

I don’t mind a few modules or one monolithic file with windows cruft thrown in there. It’s usually easy to get to the business end of stuff if it’s well written.

What slows me down is needless learning curves associated with arcane over engineering.

In my latest framework for my demos it was one of the main design decisions that the basic code anyone would be interested in should be in the Main.cpp file. For most of my simple demos it makes it so much easier for someone to read and learn from the code.
I really try to hide all those things everyone has seen already. Instead of spamming everything from glBindTexture() and loads of glActiveTexture() and glTexEnvf() etc, I just use a simple way to describe what state I want. Basically, I tell my little renderer how my state differs from the default OpenGL state. Like this,

renderer->setBlending(GL_ONE, GL_ONE);

which tells me that I’ll use the texture “base” and glBlendFunc(GL_ONE, GL_ONE). Much easier to read, plus I don’t need to care about what state I might have been in previously. Further, this kind of archetecture has really improved my own productivity an order of magnitude.

As far as I’ve seen all demos has one drawback. Mostly they are devided in 10+ files which are all the time trying to call hell-knows what functions in hell-knows what libraries not to mention about their super-configured glh_gluts etc. There is almost no ordinary C++ code visible <even about topic>. And the second option, there is one file whith poor structure. Although I’ve seen 3 relly nice & structured demos - CG labs. All includes, functions, variables etc. are well grouped & that looks realy nice I even remaked my old projects that way - takes me few seconds to find what I need & looks nice