Live data from Hacker News

Doom 3 Source code review

fabiensanglard.net

61–64 of 64 posts

Re: Doom 3 Source code review

#61
post #45

Earlier quoted context omitted.

Of course you have to know to do this.

I figured it out after about 15 seconds from seeing one of the images load on-demand. Which is the time any self-respecting computer programmer should take.

I load links as background tabs and visit them later when I am on a slow connection. When sites do things like this I end up viewing the site for the first time several minutes after clicking on it only to find that I had been waiting for nothing.

Thanks for the snark though.

Re: Doom 3 Source code review

#62
post #58

We only just found out last year why it was problematic – on windows, OpenGL can only safely draw to a window that was created by the same thread. We created the window on the launch thread, but then did all the rendering on a separate render thread I actually thought this was well known and documented as I've known it for years. Guess not :) AFAIK you can use OpenGL in other threads, but you must lock the context to…

It may be not so much "well-known" as universally observed without thinking about it. I made the same mistake id did, using SDL in fact, spawning a separate thread for SDL calls. I beat my head against it for much longer than necessary and finally ended up in the SDL irc channel, where someone firmly informed me to stop making calls from multiple threads. When I told them I was making all SDL calls from my rendering…

Both of the links you posted say that video/event functions should not be called from different threads:

Don't call SDL video/event functions from separate threads

most graphics back ends are not thread-safe, so you should only call SDL video functions from the main thread of your application

The second one specifically says from the main thread, while the first one only says "separate threads". I was always under the illusion that it didn't matter which thread, as long as its the one you cal SDL_Init from. Your experience shows otherwise...

I agree - documentation should be clear about limitations and assumptions.

Re: Doom 3 Source code review

#63
post #61

Earlier quoted context omitted.

I figured it out after about 15 seconds from seeing one of the images load on-demand. Which is the time any self-respecting computer programmer should take.

I load links as background tabs and visit them later when I am on a slow connection. When sites do things like this I end up viewing the site for the first time several minutes after clicking on it only to find that I had been waiting for nothing. Thanks for the snark though.

Right, I'm in a position such as yours every now and then. Now I understand that you meant that you can't possibly know you have to force the images to load because you have not looked at the tab yet.

> Thanks for the snark though.

I appreciate taking it in good nature :)

Re: Doom 3 Source code review

#64
post #5

>In some part of the code (see dmap page) there are actually more comments than statements. >Dmap source code is very well commented, just look at the amount of green: There is more comments than code ! You know, in my experience that's not a good thing. I work on similar, heavily-commented code and find it extremely painful. At some point it becomes a burden to see the code behind the comments. (And just so no one m…

Unfortunately bad comments like this leads people into thinking that all or most comments are useless. It's true that I don't want to see a comment like "loop through this 50 times". But what may not be obvious is the purpose of the loop, the significance of the number 50. Putting in "why" can save hours. The only exception where I would want a comment that just says what a line of code is for a really complex line,…

I agree with the point about comments being useful for a really long complicated regex, but any really long complicated regex is a coding problem to begin with. Really, instead of comments (or in addition to comments), the regex should be broken up into logical pieces separated by white-space, just like regular code is. Jeff Atwood explains it well in this classic post: http://www.codinghorror.com/blog/2008/06/regular-expressions...
Post reply on HN