Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 18 Oct 2005
Offline Last Active Yesterday, 09:12 PM

#4947912 OpenGL version?

Posted by SimonForsman on 10 June 2012 - 07:41 AM


Coming from Direct3D, I decided to make a simple game a while back in OpenGL. The tutorials I used were (I believe) in OpenGL 2.0, using the fixed-function pipeline... glBegin(), glVertex(), glEnd() etc.

I'd like to remake the game using a more recent and applicable version of OpenGL, so I can put it on my portfolio. I need to support Windows XP onwards and DirectX 9 era graphics cards with GLSL. Could anyone advise me on which version I should be looking at? From the posts I've read on GD, it looks like either 3.x or 4.x?

There's a video of my original game here, which shows what I'm trying to achieve - although I'd like to extend the game with a couple of features and GLSL effects.


For the record, glBegin, glVertex etc is the immediate mode from OpenGL 1.0.
in 1.1 you used glDrawArrays instead and in 1.5 you got VBOs. 2.0 added high level shader support.

In general you can write fairly modern OpenGL for DX9 level cards using OpenGL 2.1 (and support is far better than for OpenGL 3.x/4.x), the main problem is that the old junk from 1.0 is still available for you so learning the correct way of doing things can be harder. (most OpenGL tutorials on the net are pure junk)

#4947813 Walking Animations

Posted by SimonForsman on 09 June 2012 - 09:26 PM

You can name your animations in Blender (and probably other 3d tools aswell) and call them from your unity scripts, (watch the video and it shows you how its done).

Edit: as for figuring out which direction you're moving in relative to the direction you're looking in you can get the angle between the look vector (the direction your character is facing) and the movement/velocity vector (the direction it is moving) and go from there.

#4947616 Singleton pattern abuse

Posted by SimonForsman on 09 June 2012 - 03:53 AM

a singleton is a global with the additional restriction that there can never be more than one instance, you should only use them when you need a global instance and there would be an error if two were created. (This is insanely rare in application/game code).

Globals aren't automatically bad, globally mutable state however is usually a bad idea and wrapping your globals in a singleton class does nothing to change this, it only makes your code less flexible. (a singleton is still a global).

If you need global access to an instance you should make it an immutable global, not a singleton. If you need globally mutable state then you should rethink your design. (Allthough it is often far more important to get the job done than it is to get the design perfect).

#4947347 How to reinvigorate a team?

Posted by SimonForsman on 08 June 2012 - 07:03 AM

If people lose motivation because noone seems to be doing anything then the project leader needs to do some highly visible things to get things going.

#4944960 Game gets higher fps when executing through gDebugger

Posted by SimonForsman on 31 May 2012 - 07:02 AM

60 fps is perfectly normal if vertical synchronization is enabled. (It might be disabled while debugging) and thus its nothing to worry about.

#4944130 Multiple program files

Posted by SimonForsman on 28 May 2012 - 02:32 PM

Don't add the resources to the .exe in the first place, load them from disk instead.

#4943902 Registration, Keys, and Verification [?]

Posted by SimonForsman on 28 May 2012 - 12:01 AM

Personally i don't think it is worth it to make things "hard to crack" , if one person can crack it you've lost that race anyway, if you're going this route you should look into a service model instead. (If your application is tied to a service under your control a pirate has to replicate your service instead of removing your DRM, this will give you a far bigger piracy free window (This is the route PC games are going these days))

Businesses tend to be fairly honest when it comes to software so your best bet is to make the DRM help them keep track of their licenses to avoid honest mistakes (it also helps to offer site licenses to make the license management easier for your customers).

Individuals pirating your software can probably be a good thing, if they can't pirate your software they'll probably pirate your competitors software instead (and if the IT staff at company X runs pirate copies of your competitors software at home your chances of making a sale to company X becomes alot smaller than if the staff runs pirate copies of your software). (If you're also selling to individuals or if you have a cheaper version for individuals piracy becomes a real problem though)

#4943148 What kind of game to create if you want "decent" money out of it?

Posted by SimonForsman on 24 May 2012 - 11:32 PM

As an indie your best bet really is the casual/social market, you stand a much better chance competing against games like angry birds or farmville than you do competing against Starcraft, Left 4 Dead and Mass Effect.

Now it all depends on what you consider "decent" money though. If you want to make millions then you're in the wrong field, indie game developers don't become rich unless they're insanely lucky and good but making a living is perfectly possible if you work hard. (As you build up a code and fanbase it will become easier but you should be prepared to have to put in 50-60 hour weeks to make ends meet on your first few games)

#4943144 Sleep() not reliable?

Posted by SimonForsman on 24 May 2012 - 11:22 PM

Sleep waits for atleast the time you specify, it can and will wait for longer most of the time and thus you should never use it to control your applications framerate, only use sleep to reduce battery usage on mobile devices or cpu usage for background services.

Windows normally have a scheduler timeslice of 10 or 16 ms, so a 10ms sleep is likely to wait for 20+ms , a 16 ms sleep for 32+ms, etc (The scheduler only steps in to swap cpu control around at 10 or 16ms intervals (this can be changed using the windows API but reducing the timeslice size also reduces overall throughput of the system), if you do a 16ms sleep at the start of a 16ms scheduler interval (very likely if your actual cpu execution time is low) the scheduler will kick in after another ~15.x ms, ignore your still sleeping thread and then get back to it after yet another 16ms which gives you 30+ms delays on your 16ms sleeps. (The only way for you to get control back in time is to have other threads on the system explicitly give up the rest of their timeslices).

#4942832 Why is C++ the industry standard?

Posted by SimonForsman on 24 May 2012 - 01:53 AM

Does it mean that only C/C++ has compilers to all platforms? Why there isn't any compilers written to all platforms in other languages? Maybe there's not strong enough demand for that?

Most popular languages get compilers for all platforms eventually.

The problem really is that C and C++ are the de-facto standards, existing middleware, engines, etc are allready written in them and those will not get ported over that quickly(maybe not at all) if they have to be rewritten from scratch in a new language. This in turn means that a game platform without a C and a C++ compiler will fail miserably. (WP7 is a great example of what happens if you don't support native C++).

Since C++ almost has to be supported it is one of the few languages that a middleware writer can count on being supported on launch on a new platform which makes it the safest language to write new middleware in which keeps the cycle going.

#4942515 Broken Game as an Anti-Piracy Measure

Posted by SimonForsman on 23 May 2012 - 05:52 AM

I am usually pissed off by the "any idiot can crack it so companies are idiots to try to protect it" attitude. But it's not really present in this thread.
(that means I'm with protection, even if it cannot by bulletproof, and that pirating is a crime).
I didn't know about details, that 90% figure is quite surprising to me.

The figures for copy protected games is just as high though, thats the point of the "it will get cracked anyway" attitude, traditional DRM simply doesn't work and thus reduces the value and increases the development cost of the product for no good reason which is just as likely to hurt sales. (Increasing sales is more important than reducing piracy)

There is only really two exceptions,

1) always online DRM such as that used by Ubisoft and Blizzard as it can't just be removed (If the server runs part of the game the pirates have to re-implement the missing pieces), This can be far more of a hassle for consumers (especially those with shaky connections or for singleplayer games where people don't expect the online requirement) but it is also very effective against pirates delaying them by several weeks or even months (depending on how much they have to replicate).

2) Basic serial keys, cheap to implement and stops casual piracy. (gives a fairly high return for a minimal investment and adds very little hassle for paying customers).

Anything between those two is in my opinion a Bad Idea as its just not cost effective.

#4941151 The #'th game engine question.

Posted by SimonForsman on 18 May 2012 - 05:00 AM

- Highly detailled graphics and beautiful cloth gravity.
- Prince-of-Persia-atmosphere, mistic and great light/shadow effects.

Those 2 have nothing to do with the engine, except the cloth physics but any modern engine should support that. (Graphical quality is almost entierly dependant on shader and asset quality these days)

The rest can be done by any modern engine so why not just evaluate them to see which toolchain you prefer working with ? (You really have to do this yourself)

Also what is wrong with Unity? It is free up to one exceed a certain huge amount of dollars in annual income, and it works very well.

He needs the Pro version if he wants to use C++ and the free version has blocked alot of fairly important graphical features.

It is cheap though, getting a 5 man team up and running for pc and mac only costs $10.000 (it gets quite a bit more expensive if you want to add in iOS/Android, PS3, wii or xbox 360 support).

I also don't really see any serious flaws with Unity3D, Yes the free version is a bit crippled but thats just to push the serious developers to the pro version and while the OP said that price was no issue i don't think he should bother with engines that would cost him more than $50.000 to license unless he has a very large team in which case the cheaper options (Which tend to be licensed per seat) won't be all that cheap either.

#4939884 Question about gamedev

Posted by SimonForsman on 13 May 2012 - 03:05 PM

And for game programming which one should i pick? Java or C#? I need the one i can see results faster.

C# with Unity or XNA is probably your best bet then.

#4938678 Avoiding cheating in a multiplayer HTML5 game

Posted by SimonForsman on 09 May 2012 - 08:43 AM

The problem with this in principle is that the source code is available to the client. What I want to do is build an RTS, but I'm wondering if there is any realistic way of preventing cheating. My theory is that its not really possible, in a lockstep system, to detect whether a command has come via the user clicking or via some cheat mechanism. Also, I dont think its possible to prevent cheats such as revealing the map; basically, anything that doesn't cause a desync is possible.

Added to this the fact that the client has easy access to all the code via normal developer tools like firebug, and you have a potential disaster.

Not being a fan of obfuscation, which is easily reverse engineered, im wondering if running a lockstep simulation via websockets is not totally vulnerable to cheating.

With a lockstep RTS game there are only really 2 cheats you have to worry about:
1) Maphacks.
2) Bots.

Both can be designed around, Maphacks are made worthless if there is no fog of war and bots are only really beneficial if players benefit from a high APM and micromanagement. (If the strategy is the important part then it is very difficult to write an effective bot, just look at how common it is for RTS game AIs to be given advantages at higher difficulty settings rather than just playing better)

#4938528 How to code a swinging movement

Posted by SimonForsman on 08 May 2012 - 05:37 PM

This is basically a pendulum:

If you look at:


you'll see that the angle(in radians) between the spider and the anchor point at a given time is:

angle = initialAngle * cos(sqrt(gravity/length)*time)

That formula is reasonably accurate as long as the initial angle is below 1 radian. (around 57 degrees)

the position of the spider is then x=cos(angle), y=sin(angle) and you can simply reduce the initial angle in that calculation to reduce the amplitude of the swing. (Not physically accurate but it should work well enough for your situation).

another option is to use a proper physics model but it is quite a bit more complicated.