Console graphics

Hi all,
I've made a little console app dealing with 3d graphics. So I figured could post it here. It is using windows api, though there are only few lines of that, so I think you could easily change it to run on other systems. Any comments and suggestions appreciated.

Here's the link: http://www.mediafire.com/file/0y5ukzizm4h/renderer.zip
idk, I tend not to trust any link on the internet that leads to a zip file....
You can trust hamsterman.

Edit: and besides that, you can read the source and clearly see that it's clean. It's also very neatly written and easy to read; some open source programs aren't. GNU fdisk comes to mind...

Edit 2: one problem with this: literally the only comment in that code was a line of source code that was commented out (maths.h). Why aren't there any comments?

Edit 3: Only these lines are windows-specific:
graphics.cpp line 102, 104, 107, 108, 109, 110
main.cpp line 4, 7, 77
Last edited on
Well-writen code is self-documenting. Comments are habitually out of date or just plain lying.
I have to admit, that's cooler than dirt.
thats pretty cool :D

edit: Also sorry for the distrust..
Last edited on
Thats sweet. I'll have to really look it over as I learn some more. What type of math is involved? Thanks for including the source.
Well-writen code is self-documenting.

I disagree. Sure, his code is neat enough not to _need_ inline comments but he could at least put a description of what each function does at the top of it's declaration:
1
2
3
4
5
6
7
8
9
10
11
12
13
/**
 * swap: swap the values of the two pointers, a and b
 * @a: a pointer
 * @b: another pointer
 */
void* swap(void* a, void* b)
{
    char* pA = (char*)a,
        * pB = (char*)b,
          tmp = *pA;
    *pA = *pB;
    *pB = *pA;
}


Comments are habitually out of date or just plain lying.

Where did you get that idea from?

Are you saying i++; /* Add one to i */ is a lie? In what possible scenario is ++ going to do something other than increment i by 1 (except where i is a pointer, in which case it will resolve to something like i += (unsigned long int)(i * (sizeof(typeof(i));, and except where ++ is overloaded)?

Having said that; you're right. If code is written well enough, it should explain on it's own what it does and why. But that doesn't mean you shouldn't comment your code at all, does it?

I haven't had a chance to run it yet, because I haven't been on windows lately, but when I do (probably later on today) I'll make sure to test it out and see what's so cool :)
I'm okay with comments explaining what interface functions do. Inside the functions, unless it's for didactical purposes, not so much.

Where did you get that idea from?
Simple. Programmers know that compilers ignore comments, so they're likely not to read them. As code changes, the comments have to be manually corrected, and being the lazy effs that we are, we won't do it. A heavily commented project that's gone through enough revisions contains two programs: the code itself and its comments.
That, and the suits in code review are often confused on how comments should be done, so the poor programmers have to use specific comment templates, increasing cruft.

Commentary describes what is happening, not how, as the code itself does that. Clear code only needs commentary that describes its purpose, and only when that purpose is not evident.

Here is a nice article I just found:
http://www.codinghorror.com/blog/2008/07/coding-without-comments.html
(Watch out for popups -- I don't get them -- thanks gcampton)
Last edited on
Well that's what I said. Comments aren't necessarily, uh, necessary inside the function if the code is good (and I rarely comment inside functions).
Last edited on
That's nice work, shame that website sux balls. It opened 3 lame javascript windows about IQ testing, Casino games, and Penis enlargement...(I think those 3 go hand in hand). which wouldn't allow me to close, every time I would close a new popup would open, and when I force quit firefox from task manager and restarted firefox the same lame windows opened up. Only way to get around it was to open up some more firefox windows with a couple tabs of bookmarks and then close the first window to flush all those tabs, and then restart the computer delete cookies and start again. fun fun fun....

Last edited on
You have Adblock plus? I'd suggest getting it if you don't. Noscript is also good to grab while you're at it.
I'm glad you liked it

Why aren't there any comments?
I don't usually work with my code long enough to forget what it does and I always write it alone, so there isn't much point it writing comments for me.
That was quite amazing.

hamsterman += 5
Nice work!
I don't usually work with my code long enough to forget what it does and I always write it alone, so there isn't much point it writing comments for me.

That's fair enough. The code is still very nice. I can't emphasize this enough, but your code really is excellent. It's very easy to read and understand. But at the same time... it's still nice to see some natural language every so often :)
I just got the opportunity to try that... wow. It was awesome. Nice job!
Great job... just tried it and it was absolutely mindbogglingly mindboggling.

3D graphics on a console. :D
Nice job. Here a little code snippet to fix the console cursor (to hide it). Looks a bit better without it :)
1
2
3
4
5
	
CONSOLE_CURSOR_INFO cci;
	cci.bVisible = false;
	cci.dwSize = 100;
	SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cci);
Topic archived. No new replies allowed.