1. Post #3161
    Follow me on GitHub!
    Ziks's Avatar
    June 2011
    2,101 Posts
    How on earth does that work then
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Agree Agree x 1 (list)

  2. Post #3162
    C:\
    C:\'s Avatar
    March 2011
    1,749 Posts
    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
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Funny Funny x 15Friendly Friendly x 1 (list)

  3. Post #3163
    Gold Member
    Number-41's Avatar
    August 2005
    4,369 Posts
    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.
    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.
    Reply With Quote Edit / Delete Windows 7 Belgium Show Events

  4. Post #3164
    Andrew McWatters
    Dennab
    March 2011
    4,658 Posts
    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.
    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.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  5. Post #3165
    Gold Member
    Chandler's Avatar
    February 2006
    1,406 Posts
    In case anyone here cares, http://travis-ci.org 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 ), 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.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  6. Post #3166
    Gold Member
    Lexic's Avatar
    March 2009
    6,123 Posts
    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
    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.
    Reply With Quote Edit / Delete Mac United Kingdom Show Events Funny Funny x 4 (list)

  7. Post #3167
    Gold Member

    March 2005
    3,028 Posts
    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 stb_image.)
    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.
    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.
    Reply With Quote Edit / Delete Windows 7 Show Events

  8. Post #3168
    Gold Member
    windwakr's Avatar
    September 2009
    4,604 Posts
    did some tests, even in C modulo was a little bit faster, checked the assembly code and it wasn't optimised out.
    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;
    }
    Output:
    Code:
    % 2 loop:  5100429.43656247 microseconds
    
    & 1 loop:  2637060.52375372 microseconds
    0
    Ignore the 0 printed, I just have that so it doesn't optimize the loops out.

    Timing code from: http://stackoverflow.com/questions/1...ormancecounter


    The code may not be great, but it shows that there is a measurable difference between "& 1" and "% 2", with "& 1" being much faster.

    Edited:
    This is with signed numbers, an unsigned "m" would result in the "% 2" and "& 1" being pretty much identical.

    Edited:
    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.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Informative Informative x 1 (list)

  9. Post #3169
    Gold Member
    uitham's Avatar
    March 2010
    1,908 Posts
    I like coding shaders more than coding programs now...
    Please help me :c
    http://glsl.heroku.com/e#1770.4
    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?
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events Late x 2Friendly x 1Funny x 1Programming King x 1Winner x 1 (list)

  10. Post #3170
    Gold Member
    Lexic's Avatar
    March 2009
    6,123 Posts
    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.
    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.

    Edited:

    (Also it plays nicely with PhysFS which is useful c:)
    Reply With Quote Edit / Delete Mac United Kingdom Show Events

  11. Post #3171
    Gold Member
    Jookia's Avatar
    July 2007
    6,768 Posts
    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 musn't.

    Edit 2: If it helps, I'm sure Hitler drafted the X11 specification.
    Reply With Quote Edit / Delete Linux Australia Show Events Funny Funny x 22Agree Agree x 2 (list)

  12. Post #3172
    Zyx
    Guest 3855 is lost and can't find the park exit
    Zyx's Avatar
    February 2005
    2,839 Posts
    Snip first part.
    Keep the other.

    Also, world editing is fun. Made a small town.


    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.
    Reply With Quote Edit / Delete Windows 7 Show Events Programming King Programming King x 5Dumb Dumb x 3Disagree Disagree x 1 (list)

  13. Post #3173
    Gold Member
    drblah's Avatar
    September 2005
    189 Posts
    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!

    Reply With Quote Edit / Delete Windows 7 Denmark Show Events Winner Winner x 8Programming King Programming King x 2 (list)

  14. Post #3174
    Andrew McWatters
    Dennab
    March 2011
    4,658 Posts
    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.).



    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?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  15. Post #3175

    August 2011
    192 Posts
    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:

    Reply With Quote Edit / Delete Windows 7 Switzerland Show Events Artistic Artistic x 8Winner Winner x 1 (list)

  16. Post #3176
    open.gl
    Overv's Avatar
    February 2007
    7,431 Posts
    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
    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...



    Get to work!
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events Funny Funny x 36Winner Winner x 4 (list)

  17. Post #3177
    Richy19's Avatar
    May 2010
    5,413 Posts
    Remeber a few days ago I asked about mono and SFML speed? well turns out its almost at C++ speed for simple stuff
    http://www.facepunch.com/threads/115...1#post34897694

    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
    Reply With Quote Edit / Delete Linux United Kingdom Show Events Dumb Dumb x 1Funny Funny x 1 (list)

  18. Post #3178
    Gold Member
    Ortzinator's Avatar
    May 2005
    1,648 Posts
    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
    "Never" is a little extreme. How about "not any time soon"?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  19. Post #3179
    Richy19's Avatar
    May 2010
    5,413 Posts
    "Never" is a little extreme. How about "not any time soon"?
    Im with null here, sure games might make a move from C++ to an easier language (like java or C#) but C/C++ wont be completelly forgotten.
    Look at assembly, it still has its uses
    Reply With Quote Edit / Delete Linux United Kingdom Show Events Agree Agree x 1 (list)

  20. Post #3180
    Gold Member

    March 2005
    3,028 Posts
    If it helps, I'm sure Hitler drafted the X11 specification.
    This. X11 sucks. All the libraries that speak X11 suck. Xlib sucks.
    XCB is about as good as it gets while still implementing X11.

    But in general you shouldn't even think about touching X11 unless you're writing a window manager or a keylogger.

    Edited:

    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.
    Oh. I'm not terribly concerned with error reporting, but no png/jpeg support is a dealbreaker.
    It's actually pretty useless at that point, since anyone could implement a TGA loader in ~20 lines of code. It's practically raw image data :\
    Reply With Quote Edit / Delete Windows 7 Show Events Agree Agree x 3 (list)

  21. Post #3181
    Gold Member
    BackwardSpy's Avatar
    May 2008
    6,563 Posts
    I like coding shaders more than coding programs now...
    Please help me :c
    http://glsl.heroku.com/e#1770.4
    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?
    Hey look I made a thing! :D
    http://glsl.heroku.com/e#1780.1
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Artistic Artistic x 2Friendly Friendly x 1 (list)

  22. Post #3182
    garry's Avatar
    September 2001
    12,435 Posts
    Best JSON library for c/c++? Anyone got any opinions?
    Reply With Quote Edit / Delete Windows 7 Show Events

  23. Post #3183
    Gold Member
    BackwardSpy's Avatar
    May 2008
    6,563 Posts
    Best JSON library for c/c++? Anyone got any opinions?
    I've had good experiences with jsoncpp before.
    If you're not happy with that, apparently jansson might be worth a look as well.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  24. Post #3184
    I made WAYWO a better place
    OldFusion's Avatar
    September 2011
    1,311 Posts
    Best JSON library for c/c++? Anyone got any opinions?
    http://code.google.com/p/rapidjson/ Because its fast and i never used any other ones.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  25. Post #3185
    Gold Member
    Bluefire's Avatar
    August 2007
    323 Posts
    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.
    personally compiled and tweaked copy of vim/emacs
    personally compiled and tweaked copy of emacs
    Wait, you're telling me there's stuff that still isn't already in Emacs by default ?
    Reply With Quote Edit / Delete Windows 7 Canada Show Events Funny Funny x 6 (list)

  26. Post #3186
    Dotmister's Avatar
    May 2008
    898 Posts
    Remeber a few days ago I asked about mono and SFML speed? well turns out its almost at C++ speed for simple stuff
    http://www.facepunch.com/threads/115...1#post34897694

    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
    If you're comparing the two languages those benchmarks are silly. The only thing they really test of the native languages is how fast strings concatenate. Since the vast majority of the work done per frame is in the graphics drivers it doesn't matter at all how fast C# or C++ is.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  27. Post #3187
    Kamshak's Avatar
    July 2008
    438 Posts
    Best JSON library for c/c++? Anyone got any opinions?
    json_spirit, it uses boost and works really well, i messed with many different libs and none of them was really clear to me but json_spirit works really well and straight out of the box(if you got boost which i assume you do)
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  28. Post #3188
    ASK ME ABOUT MY PLAYBOOK INSTEAD OF COLLEGE
    icantread49's Avatar
    April 2011
    1,627 Posts
    "Never" is a little extreme. How about "not any time soon"?
    whatever tickles your pickle

    at the end of the day, if you're writing a game and you want to compile it for multiple devices (especially mobile devices), i guarantee you're gonna go with C or C++
    Reply With Quote Edit / Delete Windows XP United States Show Events Optimistic Optimistic x 1Dumb Dumb x 1 (list)

  29. Post #3189
    garry's Avatar
    September 2001
    12,435 Posts
    json_spirit, it uses boost and works really well, i messed with many different libs and none of them was really clear to me but json_spirit works really well and straight out of the box(if you got boost which i assume you do)
    I hate boost but thanks
    Reply With Quote Edit / Delete Windows 7 Show Events Funny Funny x 17Agree Agree x 3Dumb Dumb x 1 (list)

  30. Post #3190
    Gold Member
    Bambo.'s Avatar
    April 2011
    487 Posts
    It's my first time using OpenGL seriously and I'm having trouble translating things. In my Draw function I wanted to position a quad however the translating adds onto the last translate sending the quad speeding off in the direction.

    Here's the code being run in the Draw function:
    Code:
        glTranslatef( -10.0f, 0.0f, 0.0f );
        // do the rendering
        glBegin( GL_QUADS );
            glVertex3f( (0-width), (0-height), 0.0f ); // top left
            glVertex3f( (0-width), (0+height), 0.0f );  // top right
            glVertex3f( (0+height), (0+height), 0.0f );   // bottom right
            glVertex3f( (0+height), (0-height), 0.0 );   // bottom left
        glEnd();
    is there a way to... clear? the translation? i have no idea...
    Reply With Quote Edit / Delete Mac United Kingdom Show Events

  31. Post #3191
    NovembrDobby's Avatar
    April 2007
    1,157 Posts
    It's my first time using OpenGL seriously and I'm having trouble translating things. In my Draw function I wanted to position a quad however the translating adds onto the last translate sending the quad speeding off in the direction.

    Here's the code being run in the Draw function:
    Code:
        glTranslatef( -10.0f, 0.0f, 0.0f );
        // do the rendering
        glBegin( GL_QUADS );
            glVertex3f( (0-width), (0-height), 0.0f ); // top left
            glVertex3f( (0-width), (0+height), 0.0f );  // top right
            glVertex3f( (0+height), (0+height), 0.0f );   // bottom right
            glVertex3f( (0+height), (0-height), 0.0 );   // bottom left
        glEnd();
    is there a way to... clear? the translation? i have no idea...
    You can glTranslatef with reversed values (10, 0, 0).
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Dumb Dumb x 3Agree Agree x 1 (list)

  32. Post #3192
    Gold Member
    Z_guy's Avatar
    July 2005
    594 Posts
    Best JSON library for c/c++? Anyone got any opinions?
    Shameless plug
    https://github.com/Zguy/Jzon
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events Programming King Programming King x 1 (list)

  33. Post #3193
    Gold Member
    Bambo.'s Avatar
    April 2011
    487 Posts
    You can glTranslatef with reversed values (10, 0, 0).
    Oh god why did i not think of that...

    Cheers!
    Reply With Quote Edit / Delete Mac United Kingdom Show Events

  34. Post #3194
    HQRSE FUCKER
    ief014's Avatar
    September 2009
    3,070 Posts


    Saving/loading is finished.
    It can also save persistant data and send it to Lua upon loading, as demonstrated by the constant value in the video.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events Programming King Programming King x 3Friendly Friendly x 1 (list)

  35. Post #3195
    Darkest_97's Avatar
    February 2011
    186 Posts
    I just spent a half hour trying to figure out why a java school assignment wasn't working. I was using == to compare 2 strings instead of .equals().
    It was a bad time.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  36. Post #3196
    Richy19's Avatar
    May 2010
    5,413 Posts
    I just spent a half hour trying to figure out why a java school assignment wasn't working. I was using == to compare 2 strings instead of .equals().
    It was a bad time.
    I hate that about java
    Reply With Quote Edit / Delete Linux United Kingdom Show Events Agree Agree x 12Disagree Disagree x 1 (list)

  37. Post #3197
    Gold Member
    BackwardSpy's Avatar
    May 2008
    6,563 Posts
    I hate boost but thanks
    Just out of interest, why?
    I've never actually used it, but it seems like a pretty damn useful set of tools. What about it do you dislike?
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  38. Post #3198
    Gold Member

    March 2005
    3,028 Posts
    It's my first time using OpenGL seriously and I'm having trouble translating things. In my Draw function I wanted to position a quad however the translating adds onto the last translate sending the quad speeding off in the direction.

    Here's the code being run in the Draw function:
    Code:
        glTranslatef( -10.0f, 0.0f, 0.0f );
        // do the rendering
        glBegin( GL_QUADS );
            glVertex3f( (0-width), (0-height), 0.0f ); // top left
            glVertex3f( (0-width), (0+height), 0.0f );  // top right
            glVertex3f( (0+height), (0+height), 0.0f );   // bottom right
            glVertex3f( (0+height), (0-height), 0.0 );   // bottom left
        glEnd();
    is there a way to... clear? the translation? i have no idea...
    glPushMatrix(whatever)
    glTranslatef(x, y, z)
    /* draw */
    glPopMatrix(whatever)

    Small note that this is legacy OpenGL. We're moving away from immediate mode.
    Reply With Quote Edit / Delete Windows 7 Show Events Agree Agree x 2 (list)

  39. Post #3199
    Dotmister's Avatar
    May 2008
    898 Posts
    Just out of interest, why?
    I've never actually used it, but it seems like a pretty damn useful set of tools. What about it do you dislike?
    I'm guessing the fact it's an absolute monster to download / compile / use.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Agree Agree x 7Disagree Disagree x 3 (list)

  40. Post #3200
    Gold Member
    Catdaemon's Avatar
    February 2005
    2,821 Posts
    Spent today trying to figure out why SFML2 won't render my custom opengl shit or clear buffers. Decided to update to the latest version of SFML2, what harm could it do? Turns out quite a lot lol, the API has changed so I spent the rest of the day rejigging my code, only to find GWEN doesn't support this version. I then rejigged GWEN a bit and ended up with this:


    Initial results suggest the newer version of sfml fixes my existing bugs, but it's broken GWEN
    Reply With Quote Edit / Delete Windows 7 Show Events Winner Winner x 2Funny Funny x 1Friendly Friendly x 1 (list)