Jump to content

  • Log In with Google      Sign In   
  • Create Account


Karsten_

Member Since 19 Jul 2011
Offline Last Active Today, 09:56 AM
-----

#5133207 SDL and android?

Posted by Karsten_ on 21 February 2014 - 03:53 AM

I won't say i'm new to programming, however I am new to android and mobile platforms. My question is simple, How difficult, if possible, would it be to port over a game made for desktop, onto the android platform. I'm not worried about IOS, as I simply have no desire for it. Is this even possible, and excluding modifying controls, what would most likely have to be changes. It's a simple 2D platformer, that is still to early in development to post any preview pics of, or I would as I feel it could help answer my question. Oh and im using Visual Studio 2013, C++11.

 

To port your game to Android it obviously depends entirely on the complexity and dependencies of the game.

Usually I would do the following steps:

 

1) Look at all the dependencies your game has. For example, SDL, OpenAL, libPng.

 

2) Look around for Android ports of those technologies and test them out. If they are messy, then don't spend any further time with them.

 

3) Look at what dependencies your game has left and start duplicating the API but instead hook up the functionality to the underlying Java platform (via JNI). This is the more fiddly step but once you get familiar with JNI, the very large and featureful Android API does provide almost every feature you could require.

 

4) Get a very good system for debugging on the device. You are going to have to do this a lot and if your compile / test / debug cycle is fiddly it will take an enormous amount of time. I.e learn remote gdb. The time really pays off!

 

5) If you are developing the game from scratch to target desktop and Android. It really pays off to setup a build server so whilst you are developing on the desktop version (which is still easier to debug and build) you know you will be alerted if there is a compile failure on the Android side. You can also periodically test the build by simply grabbing it straight via the Androids web browser.

 

Some additional tips.

 

1) Glut has a seemingly more portable design than SDL in that it's callback system is easier to hook up to platforms that do not allow you to control the main loop yourself (such as Android and Emscripten). You don't need to use Glut but perhaps design your SDL application in a way that the main loop is in a callback. This will end up being called from Java on the Android side (unless you go with the NativeActivity which is great but only works on newish devices).

 

2) Prefer individual (swappable) technologies rather than one large massive framework. SDL, SDL_image, SDL_mixer is an example. If you need to replace SDL, you will also be required to replace everything else that relies on it.

 

3) Don't drag in dependencies when you can implement the functionality quite easily yourself. Remember that it is always easier to port your own code between platforms than it is someone elses.

 

4) Avoid locked down platforms (like you are doing with iOS). They are a massive faff unless you jailbreak them but lets be honest, that is barely a permanent solution when your original development device breaks and you have to track down another "hackable" device.




#5132350 Making WebGL game multiplayer

Posted by Karsten_ on 18 February 2014 - 09:53 AM

At the moment there is no way for a websocket to "listen" in a web browser which is a bit of a pain for peer to peer games.

If you want to stick to Javascript (to maintain a similar codebase) you can use node.js for this.

 

Otherwise I recommend http://websocketserver.de. One thing you will notice is that websocket servers are so sodding overengineered and it is almost impossible to find a simple client / server example beyond the handshake (which is actually the easy bit).

 

As for a list server, I highly recommend using IRC as the system to distribute instance server details. It is barely any bandwidth (so wont annoy other users) and also means you don't need to maintain a central server. Though for websockets to normal sockets to communicate you will still need to set up a websocket proxy.




#5131049 From C to ?

Posted by Karsten_ on 13 February 2014 - 09:17 AM

Yes, admittedly I have never even seen C11 code in the wild.

 

I still dont think MSVC fully supports C99 either which is quite annoying. Microsoft's excuse was that they would rather spend time on C++0x functionality.

Now, as a C++ developer, I agree with this choice. Unfortunately their C++ support is a bit lacking too :/

 

With Microsoft's new direction with C++ (Albeit C++/CX) perhaps we will see them make up a bit of ground here in the near future including in C support.




#5131020 From C to ?

Posted by Karsten_ on 13 February 2014 - 06:23 AM

I'd probably go C# right now. Java left me a bitter taste and not in the good way.

 

If you want an even more bitter taste, try using C# with Windows Metro... They cut out loads of classes for their core profile and does tend to cause quite a few headaches.

 

Whilst C++ is a perfectly robust language, the only one I have known not to evolve in any radical way (for many years) is C.

 

... Oh wait, you say that there is now <stdbool.h>? C99 is Madness!




#5130636 Examples of "SDL Game Development" in ANSI C?

Posted by Karsten_ on 11 February 2014 - 04:09 PM

For some of your tasks, perhaps something like this could help:
 

struct Texture
{
  SDL_Surface* surface;
};

struct Sprite
{
  struct Texture texture; // *Not* a pointer to the struct
  int frames;
  int x;
  int y;
};

What is quite cool about this is that a Sprite can now be passed into a Texture function (in C, I don't even think you would need to cast it). i.e
 

struct Texture* tex = texture_create("someimage.png");
struct Sprite* sprite = sprite_create("someimage.png");
...
texture_get_width(tex);
texture_get_width(sprite);

This technique is used in large C libraries like Gtk+. It also means if you do this form of "poor man's inheritance" on all your structures in the game, you could use a generic type of Object as the array type for example.

When using the popular component entity system (preferring composition over inheritance), I find using C is much more feasible for games development.




#5127995 old interpreter cint

Posted by Karsten_ on 01 February 2014 - 12:38 PM

I use CINT on UNIX for our build scripts where it "just works". I have never tried it on Windows. You will generally need binaries of a library in order to use them and you will often need to write your own binding layer since although CINT is C/C++ it is not running natively so you will need to bind it to native libraries (as is also required when using Python, .NET, JS and others) since there is no linking stage.

 

Fyi, CINT is a bit obsolete these days, it has been replaced by cling (http://root.cern.ch/drupal/content/cling). This is much more modern and uses clang / LLVM as a backend. Using C/C++ as an interpreter is still very much alive at CERN smile.png

 

You might also be interested in Pico C (http://code.google.com/p/picoc/). It is really light in comparison to CINT but you will still need to implement bindings to "non-core" libraries yourself.

 

 

There are also more heavy languages which you can embed like JS and Python.

The mentioned "Mono" is much heavier than JS and Python and unless you only ever use bindings that someone else has written, you will still need to be able to build native libraries and write the managed/scripted wrapper yourself anyway. I find developers always seem to forget this fact when using .NET, Java etc...




#5127795 Engine with C++ scripting?

Posted by Karsten_ on 31 January 2014 - 12:56 PM

For C++ interpreters, there is CERN's CINT project (http://root.cern.ch/drupal/content/cint) which supports scripting in both C and C++.

I really like it and use if for our expansive build system at work but I personally would not use it for creating games.

 

There is also Pico C (http://code.google.com/p/picoc) which looks much more usable for game scripting (though you would need to hook it up to the chosen engine manually). It is C only (no C++) but with the popularity of the component entity system these days, OOP is not really critical IMO.

 

If I were, you, I would do without the scripting part and look into something like Irrlicht. This is simply a 3D engine with a C++ API. Yes, a lot of people seem to not like it but frankly, the license, the ease of use and the portability of it is great for beginners.

The GoldSource engine was quite cool for mod development before Steam/DRM came along but you will need pretty decent knowledge of C/C++ before you will be productive using it. It doesn't spoon feed you unlike products like Unity or even in some respects like Irrlicht (less tutorials, documentation etc...).




#5123939 Classes and use of 'New'

Posted by Karsten_ on 15 January 2014 - 01:07 PM

  std::vector<std::shared_ptr<Car> > cars;

Looks ugly as sin* but provides fantastic functionality.

 

1) Deterministic destruction

2) No leaks

3) Exception safety

4) The pointer is guaranteed to remain the same even if the std::vector is resized. (i.e cars.at(7).get())

 

* Actually, the C# IDisposable pattern is much uglier when trying to get deterministic cleanup or resources.




#5119469 Have you made a game engine

Posted by Karsten_ on 27 December 2013 - 06:29 AM

Sony likely decided to use FreeBSD as the basis of the internal OS on the PS4 purely due to the permissive BSD 2-Clause license rather than any technical superiority that the OS has over Linux.

I think any version of the GPL license makes game studios itchy ;)

Then again, talking about licenses at this stage of engine development is perhaps not very productive. Get the engine built first and you can always swap out the parts using unworkable licenses.




#5119286 Have you made a game engine

Posted by Karsten_ on 26 December 2013 - 06:49 AM

At work we have been making a C++ 3D engine which favours portability above all else. The technology used varies per platform (The only common part is OpenGL).

 

Some of the tech used for desktop platforms is Xlib/glx, libpng, openal, libogg/libvorbis.

The consumer platforms (Android / iOS) use the underlying platform's stuff but wrapped with C APIs similar to the desktop counterparts to minimize #ifdefs and other changes to the core games.

 

All the model loading, animation and physics is bespoke and written in C (with C++ wrappers) so is perfectly portable to everything.

 

To get it up to a usable state ready for games it took two of us a couple of months. It is unlikely to be as advanced as Hodgman's but as an "indie" studio, we currently need to battle with tablet / phone support and all the gimmicky short lived technology that it brings.




#5118382 SDL or Unity?

Posted by Karsten_ on 20 December 2013 - 10:26 AM

SDL and Unity are quite different things. SDL is usually more of a core library rather than a complete game making product.

I wouldn't be suprised if the Linux version of the Unity player uses SDL as a static library. (The HTML5/WebGl / Emscripten version will)

 

For 2D development, you do not need a complete game engine so unless you are a beginner, I highly recommend SDL (_mixer and _image) since it provides image loading, audio etc...

 

If you are a beginner with an interest in programming, I still recommend learning SDL since you will learn more (i.e event based programming) and it will look better on your CV. It will also allow you to step up nicely to OpenGL if you go that direction.

 

I know Unity has recently made a push to hoover up the 2D indie game development market but it still doesn't provide much. 2D animation is simple using tools like Spine (http://esotericsoftware.com/) (or you can write your own in a couple of days).

2D collision is also very straight forward so Unity doesnt really provide much more there either.

 

Tbh, I recommend anything other than Unity for 2D games but you might want to see what others on these forums suggest. ;)




#5118335 Shaders (GLSL) in one file? Is it practical?

Posted by Karsten_ on 20 December 2013 - 04:56 AM

As Kaptein suggested, as you load the file into your program, you just prepend the correct ifdef before the shader source code before sending it to OpenGL.

Another way of doing this could be as follows.

char *sources[2] = { "#version 330\n#define VERTEX_PROGRAM\n", sourceFromFile };
glShaderSourceARB(shader, 2, sources, NULL);

This basically send the define to OpenGL just before the rest of the shader source.




#5117820 glTexBuffer and Texbuffer Objects samples

Posted by Karsten_ on 18 December 2013 - 06:35 AM

glTexBuffer is part of the OpenGL 3.1+ standard.

glTexBufferARB is part of OpenGL as an ARB  (Architecture Review Board) extension.

glTexBufferEXT is part of OpenGL as a vendor (NVIDIA, ATI etc...) extension (i.e if found you download gl2.h from NVIDIA's website).

 

So basically, if you use an old version of OpenGL you need to use the ARB or EXT versions.

 

However, if you use something like libglew, it will match the correct function (pointer) to glTexBuffer so you don't need to worry about what is providing the actual functionality, you just use "normal" OpenGL.

 

For sample implementations, you might want to look at open-source software implementations of OpenGL (such as mesa http://cgit.freedesktop.org/mesa/mesa/tree/src).




#5117556 Can you help me plot out a long-term plan?

Posted by Karsten_ on 17 December 2013 - 07:01 AM

I guess what I want to do is limit the amount of outside input necessary to build a functioning game. I want to grow as a programmer so that I don't have to rely exclusively on others in that area to create games. Plus, programming is just fun.

+1.

If you can get away from relying on products like Unity and sticking with core technology then it will certainly help you keep up as technology evolves (which is why we don't teach Unity at University).

 

If you enjoy programming and can do this, then you are in a very good position. Personally I would go with OpenGL since it is immediately portable but at the end of the day, the two APIs are very similar so porting between them is much easier than people make out.




#5115935 What should I start with ?

Posted by Karsten_ on 10 December 2013 - 10:43 AM

and udk and torque 3d are the only viable options because ce3 works only with internet [...] and an internet based engine is unpredictable.


have +1 rep on me for realizing that CryEngine is ridiculous for the online requirement smile.png. I am not sure why CryTek is wasting indie developers time with this crap quite frankly.

As for you other options, you do have more than UDK and Torque 3D. A 3D table tennis game should not be too tricky in Irrlicht, Unity or DarkGDK.

OpenGL and Ogre3D might be a bit too "hands-on" when starting out but with enough 3rd party libraries, there is no reason why they should be much more work.

MonoGame is kind of an intermediate between low level OpenGL and a high level game engine like Unity. However it has loads of sample projects that you can grab the code from effectively making it almost as full featured as a game engine.

ThreeJS is also becoming very popular if you can stomach Javascript.

My personal suggestion is start with a 2D game in OpenGL and C++. Keep with these technologies and keep building up your own codebase until you are at a level to make a 3D pong game. That way your experience grows with your codebase. Then at the end of it you can make a game in C++ and OpenGL that really does work on all platforms with suprisingly little modifications.




PARTNERS