• What are you working on? February 2012
3,497 replies, posted
• [QUOTE=Socram;34895870]Yeah that was the part that really bothered me, he's been saying stupid shit like this all year.[/QUOTE] Is the course a basic high school programming class, or a college programming course? [del]Python is sort of fun to write but it really isn't practical for anything over some quick tests or some bullshit.[/del] (Whoops, I was wrong. I guess I'll be looking more into python in the future. Some stuff sounds pretty neat!)
• [QUOTE=i300;34896297]Is the course a basic high school programming class, or a college programming course? [B]Python is sort of fun to write but it really isn't practical for anything over some quick tests or some bullshit.[/B][/QUOTE] This is not true. Python is used extensivly in web programming, scientific programming, mathematical programming and just plain old coding applications for people to use.
• [QUOTE=iPope;34896373]This is not true. Python is used extensivly in web programming, scientific programming, mathematical programming and just plain old coding applications for people to use.[/QUOTE] Really? Jee, thats cool I geuss. The more you know.
• [QUOTE=synthiac;34896279]would the optimizer not turn (123456789 % 2) into 1?[/QUOTE] Hmmm. You're right. Well it seems that I'm an idiot. I'll redo it.
• [QUOTE=Ziks;34895620]A bit late, but use ( m & 1 == 1 ) instead of ( m % 2 == 1 ). Unless I'm mistaken, modulo will require a division, which is pretty expensive.[/QUOTE] The modulo there doesn't require a division. Because the 2 never changes it can be optimized down: "m % 2": [code] ;eax = number to be modulo'd by 2 and eax, -2147483647 ; 80000001H jns SHORT \$LN6@main dec eax or eax, -2 ; fffffffeH inc eax \$LN6@main: [/code] Everything past the "jns SHORT \$LN6@main" is for negative numbers and skipped over if the number was positive. "m & 1": [code] test eax, 1 ;Does the same thing as "and eax, 1" for this purpose [/code] So the only difference between "m % 2" and "m & 1" for positive numbers is a conditional jump. But that's just because the divisor is a static number. It would use an expensive division if the divisor could change.
• [QUOTE=i300;34896297]Is the course a basic high school programming class, or a college programming course? Python is sort of fun to write but it really isn't practical for anything over some quick tests or some bullshit.[/QUOTE] This is a college level course, they actually added it this year for the first time. Apparently the intro to programming course in C++ was too fast paced for some so now they have this "Intro to Intro to programming" type class, which spends first 5 weeks on how to use the command line in Linux (riveting stuff...) and the remainder teaching basic programming concepts in Python. I have no qualms with Python mind you, it's a good language for what its for, its just his statement of it replacing C and C++ that irked me. It sucks taking an intro class like this when you already know how to program (in my opinion) fairly well. I hate to sound elitist but god there are some idiots in here. Also if anyone cares this is not a CS major, it's an visual effects major that includes like 12 hours or so of programming. I'm thinking I might try for a minor is CS though.
• Ok, changed it to rand.Next(). Same result (only slower in both cases of course).
• I really want to learn assembly, but I really can't think of anything that I could make which couldn't be done easily in a different language...
• [QUOTE=Lexic;34896433]r u shuuuuur?[/QUOTE] clearly you don't understand how much of a masochist i am; maybe writing my own version of a mod from the ground up so i can have things my own way isn't a clear depiction of this
• [QUOTE=Bambo.;34896564]I really want to learn assembly, but I really can't think of anything that I could make which couldn't be done easily in a different language...[/QUOTE] CPU feature detection.
• [QUOTE=Darwin226;34896475]Ok, changed it to rand.Next(). Same result (only slower in both cases of course).[/QUOTE] did some tests, even in C modulo was a little bit faster, checked the assembly code and it wasn't optimised out.
• I have a few hours experience in SFML. I'm going to try to make a tile engine. THIS SHALL END WELL edit: failed already
• [QUOTE=Socram;34896473]This is a college level course, they actually added it this year for the first time. Apparently the intro to programming course in C++ was too fast paced for some so now they have this "Intro to Intro to programming" type class, which spends first 5 weeks on how to use the command line in Linux (riveting stuff...) and the remainder teaching basic programming concepts in Python. I have no qualms with Python mind you, it's a good language for what its for, its just his statement of it replacing C and C++ that irked me. It sucks taking an intro class like this when you already know how to program (in my opinion) fairly well. I hate to sound elitist but god there are some idiots in here. Also if anyone cares this is not a CS major, it's an visual effects major that includes like 12 hours or so of programming. I'm thinking I might try for a minor is CS though.[/QUOTE] Our first exercise session (for 2nd year College Physics) in C++ was already using classes and all that stuff. Skipped the Hello World stuff right away.
• [QUOTE=Socram;34896473]It sucks taking an intro class like this when you already know how to program (in my opinion) fairly well. I hate to sound elitist but god there are some idiots in here.[/QUOTE] Test out if given the opportunity, or sit back and enjoy what you can of the course. I think this upcoming semester I'll have time to take intro to C++, and while I don't see it being very entertaining, it'll give me the chance to blow time outside of the house.
• In case anyone here cares, [url]http://travis-ci.org[/url] just added python and perl to their list of supported languages. I set it up for my build system (yeah I'm just gonna trudge through with it. I think I also figured out my performance issue :v:), and it's really neat. One of the PITA issues with python is getting a decent continuous integration system that "just works" and doesn't require the JVM to run, or a simple config system. I kind of wish they would use tox for generating information, but oh well. It works with python 3.2, that's good enough for me. I figured some of you here might want to use it for unit-tests or something.
• [QUOTE=amcfaggot;34896749]clearly you don't understand how much of a masochist i am; maybe writing my own version of a mod from the ground up so i can have things my own way isn't a clear depiction of this[/QUOTE] I'm surprised you're still in the win32 world then. The heady world of GUI Linux coding is so full of excessively complex required configuration that you'd probs pop a boner every time you opened your personally compiled and tweaked copy of vim/emacs with all your hand written plugins and cfg files.
• [QUOTE=Lexic;34895763]GLFW gives you an ultra light-weight no-frills simple and basic way of opening an OpenGL context and receive user input. (Keyboard/mouse/joystick.) Everything else is up to you. (Don't use the texture loading facilities, they're terrible. Try something like [url=http://nothings.org/stb_image.c]stb_image[/url].) I really like it. The only blot is the complete lack of error reporting. If it fails, you have to use a debugger to find out why.[/QUOTE] Just out of curiosity, why should the texture loading routines be avoided? I already have a loader for uncompressed tga (written in C) and png (through libpng) images, and I can salvage my libjpeg, etc, code from another project. However, using the GLFW provided functions would shrink my codebase and it is appealing to me to make the most of the fewest number of libraries possible. At first I was concerned that GLFW might not be able to handle sRGB textures, but it looks like you can decode the images with GLFW separately and manually load the data into OpenGL.
• [QUOTE=Nighley;34896821]did some tests, even in C modulo was a little bit faster, checked the assembly code and it wasn't optimised out.[/QUOTE] Are you positive that something wasn't being optimized out? The compiler optimizes out anything that's unused. [code] #include <windows.h> #include <iostream> #include <iomanip> using std::cout; using std::endl; using std::setprecision; double PCFreq = 0.0; __int64 CounterStart = 0; void StartCounter() { LARGE_INTEGER li; if(!QueryPerformanceFrequency(&li)) cout << "QueryPerformanceFrequency failed!\n"; PCFreq = double(li.QuadPart)/1000000.0; QueryPerformanceCounter(&li); CounterStart = li.QuadPart; } double GetCounter() { LARGE_INTEGER li; QueryPerformanceCounter(&li); return double(li.QuadPart-CounterStart)/PCFreq; } int main() { int m = 1; int a = 0; double l1 = 0.0; double l2 = 0.0; cout << "% 2 loop: "; for(int i = 0; i < 4; i++) { m = 1; StartCounter(); while(m != 0) { a += ((m % 2) != 0); //modulo can also return -1, so we do this to make both loops always add the same things. m += 1; } l1 += GetCounter(); } cout << setprecision (15) << (l1/4.0) <<" microseconds\n\n"; cout << "& 1 loop: "; for(int i = 0; i < 4; i++) { m = 1; StartCounter(); while(m != 0) { a += ((m & 1) != 0); //See the comment in the first loop. m += 1; } l2 += GetCounter(); } cout << setprecision (15) << (l2/4.0) << " microseconds\n"; m+=a; cout << a << endl; return 0; } [/code] Output: [code] % 2 loop: 5100429.43656247 microseconds & 1 loop: 2637060.52375372 microseconds 0 [/code] Ignore the 0 printed, I just have that so it doesn't optimize the loops out. Timing code from: [url]http://stackoverflow.com/questions/1739259/how-to-use-queryperformancecounter[/url] The code may not be great, but it shows that there is a measurable difference between "& 1" and "% 2", with "& 1" being much faster. [editline]...[/editline] This is with signed numbers, an unsigned "m" would result in the "% 2" and "& 1" being pretty much identical. [editline]...[/editline] Also, if you keep "m" signed but only deal with positive numbers(so it doesn't have to execute all the other instructions to preserve the sign), the "% 2" loop is ~3x slower. So, you should only use "% 2" when the dividend is unsigned.
• I like coding shaders more than coding programs now... Please help me :c [url]http://glsl.heroku.com/e#1770.4[/url] I guess I do it because you can do more with less code, I mean 31 lines for this, including comments! Also since when did Gran PC have a green name?
• [QUOTE=ROBO_DONUT;34897198]Just out of curiosity, why should the texture loading routines be avoided? I already have a loader for uncompressed tga (written in C) and png (through libpng) images, and I can salvage my libjpeg, etc, code from another project. However, using the GLFW provided functions would shrink my codebase and it is appealing to me to make the most of the fewest number of libraries possible. At first I was concerned that GLFW might not be able to handle sRGB textures, but it looks like you can decode the images with GLFW separately and manually load the data into OpenGL.[/QUOTE] They can't deal with file errors or any format other than uncompressed targa. You also don't get any kind of response to such errors (or anything like "file not found") other than GL_FALSE. stb_image on the other hand can load all common file formats, has several different levels of error reporting and is compiled into your project as a single .c file. [editline]27th February 2012[/editline] (Also it plays nicely with PhysFS which is useful c:)
• Don't. Write. X11. Use SDL or SFML. DO NOT WRITE X11. Use GLUT. FUCKING LISTEN TO ME DON'T FUCK WITH X11. Linux isn't like Win32, you don't have a monolithic blob. X11 creates windows, but you still need to contact the window manager about fullscreen windows, and Xrandr about changing resolutions, and then catch segmentation faults to make sure you reset the resolution or you fuck up the desktop, and you have to make sure you don't grab input or you fuck up window managers, and lots of other shit. Edit: I'm not trying to stress that you shouldn't write X11 code. I'm stressing that you [b]musn't[/b]. Edit 2: If it helps, I'm sure Hitler drafted the X11 specification.
• Snip first part. :v: Keep the other. Also, world editing is fun. Made a small town. [img]http://dl.dropbox.com/u/99717/NewCity.png[/img] Adding more tiles is also really easy. Whenever I run out of empty tiles in the tileset I just expand it and change a number in the code. And right click on a tile to select that texture.
• Just finished my Arduino/C# network monitor. It is basically a line of LEDs lighting up as my download speed increases. The C# program allows you to choose which NIC you want to monitor and which serial port the Arduino is connected to. The speed is transmitted in Kb/s which is then mapped by the Arduino to fit the 7 LEDs. It is probably very inaccurate and all that jazz, but it works! [media]http://www.youtube.com/watch?v=W3Td-2NsMgM[/media]
• Yo, MSVC homies, I gotta problem. More of what I was doing last night: This is really starting to piss me off because this shit makes me run around in circles (sometimes literally, in code speak) and doesn't point at the actual problem. Generally what I see is a manifestation of an issue elsewhere (invalid casting, etc.). [t]http://img836.imageshack.us/img836/2446/gamehl2sb2005debuggingv.png[/t] When debugging, (and I'm sure this is probably a 2005-exclusive issue) I get shit like this. Data looks valid to the code, and doesn't segfault, and this occurs whilst my debugger says it's null or just invalid data, etc. Can anyone explain to me why this occurs, and if it occurs outside of Source projects? Perhaps the pointer it's showing me is to memory that it found earlier on but not an exact representation of the pointer as it is right where my breakpoint is or wherever I'm stepping?
• hm, I guess I have to retry it. I was pretty sure that % was faster but of course it wouldn't make sense as % does divide the number and that is significantly more work for a CPU than just byte operations but then again I was just too busy drawing my new higher resolution sprites: [IMG]http://dl.dropbox.com/u/22597917/hires.png[/IMG]
• [QUOTE=amcfaggot;34896749]clearly you don't understand how much of a masochist i am; maybe writing my own version of a mod from the ground up so i can have things my own way isn't a clear depiction of this[/QUOTE] Haha, I know a lot of programmers are like this (myself included), but one could then argue that you should write the matrix and vector math yourself as well. And, as was stated by someone earlier, X11 is so horrific that no sane Linux developers touch it directly. By the way, Maurice... [img]https://lh3.googleusercontent.com/-Mpm7Ov1fYf0/T0kXZNttPOI/AAAAAAAAVng/YYtIuqNfTKM/w350/Chuck+Norris.gif[/img] Get to work!
• Remeber a few days ago I asked about mono and SFML speed? well turns out its almost at C++ speed for simple stuff [url]http://www.facepunch.com/threads/1152030?p=34897694&viewfull=1#post34897694[/url] its slow due to my laptop but both programs (C++ and C#) take around te same time to draw and such. Might give some people something to think about :P
• [QUOTE=icantread49;34895918]C/C++ aren't ever going anywhere, enjoy finding a language to write a game in that runs on multiple platforms, including mobile platforms, without resorting to virtualization[/QUOTE] "Never" is a little extreme. How about "not any time soon"?