Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 05 Oct 2002
Offline Last Active Feb 26 2014 05:48 AM

#4902226 Witch should I learn first: SDL or OpenGL? (C++)

Posted by dublindan on 12 January 2012 - 10:38 PM

I'd suggest not wasting any time on SDL. SDL is outdated, and lacking many features that SFML provides.

Not true. The latest version (SDL 1.3) is up to date. Check out the docs here. SDL 1.3 uses OpenGL for its rendering backend, supports multiple windows and so on.

SDL has fewer high level features than SFML does (SDL does have addon libraries for some of these features though). For example SFML has image loading built in, but in SDL you would usually use something like SDL_image. SFML does provide a lot more rendering primitives than SDL does (eg, shaders) - SDL definitely aims to be lightweight and low level (eg a thin layer to handle windowing and input while you use OpenGL directly).
SDL has a C API instead of an object oriented C++ API like SFML has. SDL supports more platforms. SFML has networking support built in, SDL does not (but again, theres an addon library for it). SDL 1.3 documentation is still very much a work in progress though, while SFML has solid documentation. Besides that, they are more or less equal.

If you go with the old SDL 1.2, it has a lot of documentation available too and is rock solid, but you lose out on a lot of features like hardware accelerated rendering (unless you manually use OpenGL) and multiple windows.

Having said all that, I would suggest using SFML since it will get you started quicker. SDL would be a good choice for someone who already knows what they are doing and want a base to build a custom engine on top of, but SFML would be, IMHO, a better choice to get started quickly and learn game programming since it provides many more high level features, but these may get in the way if you are trying to build a truly custom engine (which, unless you're an expert, you shouldn't be doing anyway).

#4885901 Choices

Posted by dublindan on 20 November 2011 - 09:58 AM

I tried to learn C++ and gave up after a couple of days

I'll just say two things on this point.

First, learning to program will take a long time - certainly a lot longer than a few days. Should you want to learn to program (and you don't have to - you can focus purely on art; but being able to prototype your own simple projects is useful and understanding what the programmer is talking about, when you find one, would also be helpful), it will take a lot longer than a few days, even just to learn the most basic concepts and to become an expert will take many many years. Basically, if you want to learn, don't give up so soon.

Second, C++ is a notoriously difficult language for beginners (and even for experts!), I would highly highly recommend learning another language first. You will not notice any difference in performance (or other reasons people typically use C++ for games) at your level, so it is not worth worrying about it. When the time comes where your projects would benefit from being done in C++, you will either have other programmers to do it for you, or you will be ready to learn it yourself (and it will be a lot easier to learn when you already know another language). My recommendation for a beginner language is Python, as it is very easy to learn, support everything you would expect from a modern programming language, has some excellent books and a very active community in case you need to ask for help.

and anyway I suck at advanced mathematics.

So do I, but it has never held me back too much.

Programming isn't really as much math as people make it out to be. Some understanding can be quite useful, especially some knowledge of logic, but you will get by just fine without it. If you are making a 2D game, you will use surprisingly little advanced math (a lot of basic math for stuff like movement and controlling the camera and physics, but nothing terribly demanding). 3D graphics do require a lot more advanced math, but if you use an existing game engine (which is a good idea anyway), most of this will have been done for you.

So I would like to know if it is okay when the time comes and after I find a programmer to leave every choices of programming my project to him, such as language choices, creating an engine or not...

Yes, definitely let the programmer decide! Unless you do learn to program yourself, and therefore participate in the programming, you shouldn't tell the programmer how to do their job. You wouldn't want the programmer to tell you what colors you can use or if that you should use Inkscape instead of Photoshop or whatever.

Do programmers who participate in other people's project mind or Don't they mind whether it's them or the project owner who chose?

Unless the project owner is an expert programmer, or there are some very good reasons to have the decision made for them (eg, if you are making an XBOX Live game, you probably want to use XNA and C#), the decision should be left up to the programmer. After all, it is the programmer who has to do the programming, so you should let them decide how to best do this. You wouldn't ask a mechanic to fix your car, but then tell them which tools you wish them to use, would you?

Most people hate being told how to do their jobs by people who are not qualified to do it themselves.

I'm afraid the programmer will say something like "you don't even know which language you want the game to be written in, I don't think you're serious about your project so don't count me in".

Quite the opposite! If you are not qualified to make the decisions, leave them up to somebody who is. Show that you are serious about a project by doing what you are qualified for (in your case, I guess, by creating awesome art assets for the game).

It may be a better idea for you to use some game making utility that already has an engine ready to use, because all you want to do is make the art assets and game part.

This is good advice. It also shows potential future collaborators that you are serious, have good ideas and are good at what you do. Basically, it lets you prove yourself, but it also lets you find out for yourself what works for you, so that when you do go ahead and program something (or have someone program it for you), you already have a good idea what you want and how everything should work.

I would not worry about finding a programmer until you have worked on a few personal projects first. That way, you have more to show for (and you will have refined your skills) when you try and attract a programmer to help.

#4836635 why is C++ not commonly used in low level code?

Posted by dublindan on 17 July 2011 - 10:23 PM

1- C is used in embedded systems because it is ( as a system ) small and easier to implement, and has a lesser footprint, especially when you are talking megabytes of available RAM.


I have worked, and have friends that continue to work on embedded systems, and C is still the reigning champ. This is because implementing C ( and it's tool chain ) is a hell of a lot easier than C++, and has a smaller footprint, while at the same time, the code complexity of embeded systems is generally quite small, so what C++ brings to the table really isn't required.

Nowadays, I do a lot of embedded systems work, mostly on the PIC24 line of 16bit microcontrollers and I use a mix of C and assembly. While I'm certain that for a lot of people your points are true, they certainly do not aply to everyone: the reason I use C over C++ is not for any of the reasons you gave (except perhaps the C compilers are easier to implement, in an indirect way), but rather that of availability. There are good C compilers available for PIC24's, but I have yet to find a good C++ compiler (or any other langauge I know). If there was a good C++ compiler, I would use that instead. The lack of availability of other language compilers could be down to a number of reasons including historical reasons and the fact that C compilers are easier to implement.

This doesn't invalidate what you said at all, but rather brings up another reason: availability.

#4835110 Should I choose hardware engineer or software engineer or programmer as my ca...

Posted by dublindan on 13 July 2011 - 09:33 PM

My vote is to go into hardware simply because thats where I've been finding myself headed lately. My background is in software. Learned to program because I wanted to make games, got a degree in computer science, worked in telecommunications (backend server stuff for mobile networks) and web development (mostly backend, a little javascript/html/css) and now I'm starting a hardware startup, kinda. Still learning a lot about electronics, getting pretty intimate with certain microcontroller datasheets and building cool gadgets. Just today I was working with a bluetooth module connected to a PIC24 microcontroller. Lots of interesting stuff to learn and fun things to program.

Of course, I always liked low level stuff, from embedded systems to operating systems to compilers. The assembly and computer architecture courses I took in uni were probably my favourites. Also, I have no idea what kind of job a typical electrical engineer can look forward to. Dunno if what I seem to have slipped into is the norm in the field or not, but I'm loving it so far!

I still do a lot of programming: firmware, tools and scripts. Not to mention that I still do a little web development work. I love programing though and I love using various languages and this lets me use C, assembly, C++ and Python on a regular basis.

What should you do? I don't know. I think you need to try out a few different things first. Get some exposure to the various fields in both hardware and software. See what you like and what you don't like. See what you're good at. Learn some new things in the process.

Also, be prepared to learn somehting new and switch careers later, especially if its to a complementary field. Who knows if you still want to do the same things in ten years as you do now. Ten years ago, I sure didn't see myself doing what I do now.

#4811068 Doubts about strategy of rendering

Posted by dublindan on 15 May 2011 - 07:41 AM

Shaders are a whole other beast entirely, but when you're ready for them you should be able to integrate them into your VBO renderer without too much trouble.

I recently embarked on the adventure of learning shaders and was surprised at how easy they really are, once you understand the basic concepts. I mean, I'm not writing anything terribly advanced yet, just simple stuff like animating vertices, generating new vertices in geometry shaders, applying textures and effects (blur, ripple, pixellation so far) in the fragment shader and its really easy to do. And a lot of fun to see the results! Soon I will try more advanced stuff, so I'll see how that goes, but for reasonably simple stuff learning GLSL shouldn't be a problem.

Thank you, this thread encouraged me enough to stop thinking about the problemsand move on to implementation. My concern is to maintain 60FPS running the program on a notebook is not very new. My graphics card is an ATI Mobility Radeon2400 so it is not very powerful. But I hope that your dedicated 256mb is enough:).

I was thinking about creating something with GLSL for mapping textures in mysquare. That would be more efficient than simply using the opengl commands?

Sometimes I confuse what can be done in GLSL to improve performance.

Thank you all.

Well, as I see it, the GPU is great at taking in a set of commands and then applying them to a large amount of data (thats hopefully already in VRAM) without any further instruction from the CPU. As such, the more you can have the GPU do without CPU hand-holding, the better. For example, I am going to be animating and moving all articles in my particle system in shaders, so the CPU just tells the shader about new particles and then the GPU handles them from there (no need to copy them back to the CPU). Keep the GPU busy with graphics related stuff and free up the CPU for gameplay, physics and AI.

Once you use GLSL for anything, you have to do texture mapping through it too. But don't worry, texture mapping is really really easy to do in GLSL.

#4810671 Im sorry, I am stressed

Posted by dublindan on 14 May 2011 - 08:19 AM

thx guys, I feel like a high wall is obstructing my way. and no matter how hard I try to crush it, it wont budge. I feel so limited...

I know this feeling all too well. When things dont go your way, its easy to forget the times when everything went really well.

For example, as I showed in another thread, I recently built an almost-custom MIDI controller. It works and right now I'm very happy. But if you had asked me a few days ago when I thought I'd blown the SECOND circuit board (replacement would have cost €70 and would have taken three weeks to get here), I would have told a different story. It was the worst feeling ever. Frustration and a sense of uselessness - nevermind that I had other successes not too long before that. Its all too easy to get fixated on the most immediate problems and feel that the world is against you and that you can't do whatever it is you want to do. I guess we all need to take a step back every once in a while and recognise our successes too.

Ok, I know I only talked about success and failure while you are talking about religion.
I think its related though - I take it you believe (or before this believed at least) in god? In that case, what has changed? A feeling that the world (and therefore god) is against you? That things don't go your way and that you are unlucky? You make your own luck and the success/failure thing will show you that the world probably isn't against you. I've had my fair share of depression and know exactly how you feel. I've had identity crises which left me wondering what the point of it all really is. I'm still here and while my life is far far from perfect, I am doing things I enjoy. I quit my job so I can focus on things I love instead of things I'm told to do. Sure, I'm poor as hell now, but I'm learning a lot and doing things I love (and I'm working on the money problem too, so hopefully soon that won't be an issue anymore).
You need to make time for things you love too. If those same things are whats frustrating you, then you need to take a break from them for a while and do something completely different (but still enjoyable; maybe you'll find a new hobby you didn't realize you enjoyed, bonus points if its a sport or something physical since that helps clear your head. Physically building something is good too. Something outside is probably better than something inside).

#4810047 The importance of hardware knowledge?

Posted by dublindan on 12 May 2011 - 07:54 PM

How many of you would be able to make a working, programable computer? (i.e. not from pre-built parts)

Please explain this question. What counts as a prebuilt part? Certainly a motherboard or graphics card, but what about a RAM module? A processor? A microcontroller? EEPROM chips? Logic (ie AND, OR NOT, 555 timers etc) chips? Transistors? Resistors? Capacitors?

Where do you draw the line?

If you really do mean NO pre-built parts, then I don't think theres very many people who could do it. You mention the £15 computer that guy built, but he uses plenty of prebuilt things: ARM processor, USB controller, EEPROM, SD card reader, oscillators, resistors, capacitors, wiring (I'm taking an educated guess as to what parts he used - I did not look it up). If you have to build everything from scratch, what about purified silicon?

It of course is possible to do this and thats how we eventually got to where we are today, but there is a LOT of detail and many many components in a modern computer. I doubt any one person could build one from scratch from nothing.

If I can use basic semiconductor components and basic logic and memory ICs, I could possibly build you a very very very simple computer... but it wouldn't really resemble a modern computer and not be nearly as capable.

#4808333 What is the best library for loading images?

Posted by dublindan on 08 May 2011 - 07:36 PM

I certainly don't know about best, but I've always used SDL_image (and use it in my current project to load PNG files). It is insanely easy to use and supports the following image formats: BMP, GIF, JPEG, LBM, PCX, PNG, PNM, TGA, TIFF, XCF, XPM and XV.

Of course, SDL_image returns an SDL_Surface*, so if you are not using SDL, this may be an undesirable dependency.

Here is a code snippet for loading an image and using it as an OpenGL texture:

// initialize SDL_image for loading PNGs (you can tell it to initialize "everything" if you like). Real code should check the return value.

// OpenGL texture id
 GLuint texture = 0;

SDL_Surface* tex = IMG_Load("image.png");
    glGenTextures(1, &texture);
    glBindTexture(GL_TEXTURE_2D, texture);
   // If BytesPerPixel is 3 then the image is 24bit RGB, if it is 4 then the image is 32bit RGBA. We won't bother supporting anything else.
    const GLint gl_format_list[] = {0, 0, 0, GL_RGB8, GL_RGBA8};
    const GLint img_format_list[] = {0, 0, 0, GL_RGB, GL_RGBA};

    glTexImage2D(GL_TEXTURE_2D, 0, gl_format_list[tex->format->BytesPerPixel], tex->w, tex->h, 0, img_format_list[tex->format->BytesPerPixel], GL_UNSIGNED_BYTE, tex->pixels);


#4808084 What happened to the pc game industry?

Posted by dublindan on 08 May 2011 - 08:15 AM

PC gaming is still going strong on online content providers like Steam and Impulse. I guess stores find console games more profitable, but honestly I stopped buying CD versions of games long ago because I found them too inconvenient (plus they get scratched). Steam (and to a lesser extent, Impulse) have provided me and my friends with almost every game we've bought over the past four or five years.

I did buy sins of a solar empire on dvd, but only because it was just a few $ more than the digital version to geth the boxed version as well so I could play the digital version while I waited for the CD to arrive (I dont think I ever opened the box actually). Having said that, the few CD games I did buy were all bought online too.

But yeah, stores seem to stock very few, if any, PC games these days.

#4807534 Selling eternal life! Is anyone interested?

Posted by dublindan on 06 May 2011 - 05:44 PM

You wouldn't live forever... the copy of you on the computer might though.

It's essentially the same thing

No, its not. Think of it this way: when you create the artificial "you" but don't die yourself, there are now two of "you". You will look at it and say "here is a copy of me", but the original will still be "you". Your consciousness will not be transferred - only your memories. When the original dies, the copy will still exist, sure, but what you identify as yourself - your consciousness and sense of self - will have died along with the copy.

If I can exist at the same time as something else - that something else cannot be "me".

FWIW, an artificial neural network only approximates the operation of neurons in a biological brain. There is a lot more going on in a brains neuron than you would think - both electrical and chemical processes. To create a copy of a complex living organism is still way way beyond us. Making such a copy take on the originals consciousness and sense of self is something I doubt will ever be possible. Religious people would say that you may be able to create an exact copy of the body, but you cannot transfer the soul. I believe that consciousness is created by something religion refers to as a "soul" - whatever that may be. Maybe one day we will be able to explain it scientifically, and maybe then we will be able to live forever by transferring it into a new body, but if it will ever be possible at all, it will be long after our lifetimes.

However, the technology for full immersion virtual reality may well be possible in the not *too* distant future. I'm told by a good friend of mine, who is doing research in brain-computer interfacing and has spent a lot of time hanging out with neuroscientists, tells me that bidirectional brain interfacing isn't all that far off, but that ethical issues will likely hold it back (eg, how do you perform the initial tests required for an invasive brain interface when doing so could seriously damage the brain, injuring or killing the subject).

Storing your brain on a disk is nothing but an inert copy. Pretty useless, unless the copy is executed in a system that gives it self awareness.

Also, you can not transfer your own self onto a different medium. The moment the copy is 'alive', it will be an independent sentient being, with its own unique experiences. It may have your memories, but it will be no longer you.

Gradually replacing one's brain cells with synthetic ones could do the trick there. Still, all the hormonal influence that is a big deal in relation to one's temperament would be missing.

This is an interesting possibility which may or may not be possible in the future. Repairing your existing body may well extend your life indefinitely and is very different from creating a copy like the OP suggested.

I don't know if I would want to live forever though (longer perhaps, but not forever) - think of the overcrowding! (Presumably we will have technology to terraform other planets then, but I think we will probably annihilate each other in a big war first - more people = more conflict and poverty = more destruction and death).

#4803128 Need Help with a great idea

Posted by dublindan on 26 April 2011 - 10:23 AM

Ok, a few more points to think about:

I have an idea that I absolutely KNOW will be a success and will actually, well

How do you know this? A lot of seemingly great games based on great ideas are a giant failure. Like I said before, execution is more important than the idea. What I didn't say before is that sometimes terrible ideas, with terrible execution are successful because of amazing marketing. Similarly, sometimes brilliant ideas, with brilliant execution, but terrible marketing fails. I guess you can include marketing as execution, though (development + marketing = execution, I guess).

My point is that it is very hard, even for large developers and publishers, to know if an idea will be successful or not (which is why we have so many sequels - they like to go with things they have already seen be successful).

I guess WOULD actually be something that I as a gamer, that loves first person shooters, especially online and everyone else would just love if it were available as a feature of their favorite online multiplayer shooter game.

Maybe you're right (I'm not trying to imply you're wrong or that your idea isn't a good one with my replies!), but I've often seen this quote: "Gamers make terrible designers". Of course not all gamers make terrible designers and I hope that designers are also gamers themselves, but the point of the quote is that every gamer and his dog thinks they can do better, thinks they know better than each and every designer that came before, thinks they have some special insight other designers didn't and thinks they know what every gamer want. In reality, these people usually know what THEY want [1], even though it often unbalances the game and ruins it for everyone else (except the small group who happens to have similar tastes).

Does this apply to you? I don't know. Maybe, maybe not. Its just something you should think about and decide for yourself. In any case, maybe this will help you to make your idea better. Or maybe you have already considered this, in which case, just ignore it :)

[1] even then, they may think they want something but if it were ever implemented, they'd find that it really isn't that fun


You may not be able to patent it at all, if it doesn't constitute a process or invention and the other things mentioned by others. You may have to ask a lawyer about it, but I don't know, I've never filed a patent.

Now, having said all that, feel free to contact me in private should you want to discuss it. I don't have time to develop anything and have lots of ideas of my own, so can't help you actually implement this, but I may be able to point you in the right direction to either build it yourself or find others who may help. If you do intend on contacting me, just be aware that once you tell ANYBODY about your idea, it is no longer a secret under your control (ie, if you tell somebody you cannot realistically stop them from telling somebody). I just want to make it clear that telling anybody (myself or somebody else) about it, pm-logs or not, means it is no longer in your control. For example, even if you patent it in the US, somebody in another country may still be able to safely copy you. But, as I said already, I think that this happening is extremely unlikely.

#4802648 Here's un pregunta for you, "Do your friends suck?"

Posted by dublindan on 25 April 2011 - 07:23 AM

Even computer science students don't write single line of code except school projects and exams.

That part annoys me. It's surprising how many students (even my coworkers who are juniors or seniors in their CS or CIS degrees) have no interest in programming outside of their degree. I showed my CS coworker a multiplayer game I made in the browser and instead of being like "cool how does it work", like an old CS graduate I knew, he was like "I bet that was hard" and goes back to facebook. :(

...and then complain when they can't find jobs!

#4802493 SDL tictactoe

Posted by dublindan on 24 April 2011 - 07:07 PM

The problem is that you are recreating the Target objects in your loop (the while loop in main). Every iteration of the loop, you create new objects, process them (set taken to true, if you click on them), then the objects are destroyed and new ones are created. To fix this, move the Target myTarget1 = Target(...); ... code out of the loop (before the while(quit == false)).

Here are some tips on improving the code:

  • Make taken private and add taken = false; into the constructor (Target::Target()). This will let you remove the myTarget1.taken = false; from main.
  • Inside Target::handle_events(), you do not need to prefix taken with Target:: (so Target::taken becomes just taken).
  • Consider making event a local variable in main and passing it to Target::handle_events() instead (so handle_events() becomes handle_events(SDL_Event& event) - the & means pass-by-reference and is similar to passing a pointer, except that the function can treat it as a normal variable ( . instead of ->, no need to delete its memory etc)).
  • Create an array (or an std::vector) of Target instances, instead of myTarget1, myTarget2 etc:

#include <vector>

int main ( int argc, char *args[] )
    //check for errors
    bool quit = false;
    if( init() == false ) { return 1;}
    if( load_files() == false ) { return 2;}
    apply_surface( 0,0,background,screen);

    // set up targets (taken is automatically set to false in the constructor)
    std::vector targets;

    // Local variable, instead of global
    SDL_Event event;

    //game loop
    while (quit == false)

            // When you learn more about std::vector, replace this with "iterators" instead
            for (unsigned int index=0; index < targets.size(); ++index) {

            if( event.type == SDL_QUIT )
                //Quit the program
                quit = true;
        if (SDL_Flip( screen ) == -1)
            return 3;
    return 0;

#4802485 PySide problem

Posted by dublindan on 24 April 2011 - 06:33 PM

You could try running the exact same program in PyQt (which is pretty much code compatible with PySide) and see if it works. If yes, then this means that its possibly a bug in PySide - you can report it to their bug tracker, or ask on their IRC channel or mailing list. You can then either see if they fix it or provide you with a workaround, or you can use PyQt instead (if the PyQt license is acceptable for what you are trying to do - PyQt is released under a dual GPL/commercial license; PySide is, afaik, LGPL).

If, on the other hand, that too crashes, then there is a problem with your python installation or set up.

#4800737 POD detection in C++?

Posted by dublindan on 20 April 2011 - 06:35 AM

Boost has is_pod, which works well for me. One advantage of detecting if a type is a POD type and handling it with placement new is that you can omit calling the destructors when you're done (ie, you can just pretend the pre-allocated array is unused). In my own code, I use this in a stack class, where during a frame I allocate objects off the stack and at the end of the frame, the entire stack gets thrown away (and if it only holds POD types, this means simply resetting the stack pointer to 0). For everything else, I use standard library containers and TBB containers.

It's not a bad response to a beginning C++ student but when all you get is spam saying stl is great or check out some stupid boost feature instead of answering the actual question it keeps real answers from coming along (if any are coming, or are even possible which seems like shot in the dark in this case).

That stupid boost feature IS the real answer to your question. Quite honestly, your offhand discounting Boost and its features makes you look quite inexperienced, so I think what everything said by everyone else is appropriate. Especially pointing you towards Boost. The other answers are also real answers - yes, they don't answer your specific question, but they are reading between the lines telling you why your assumptions might be incorrect. If you are sure that you are correct, then great - ignore those posts (they will help somebody else who comes to this thread with the same question as you), you already got a good answer: Boosts is_pod<T>.