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!


Karsten_

Member Since 19 Jul 2011
Offline Last Active Yesterday, 01:28 PM

#5115446 What Language or Languages for Web and Mobile Apps

Posted by Karsten_ on 08 December 2013 - 02:45 PM

The Emscripten project (https://github.com/kripken/emscripten) will allow you to port your C++ code over to Javascript with minimal changes. If you use open technologies such as OpenGL, SDL, OpenAL etc... then this task is almost trivial.

Emscripten is a rapidly maturing project (sponsored and actively developed by Mozilla). You might want to give this a shot (at least until the "desktop" becomes cool again ;)).


#5115443 Win32 programming, relevant in windows 8?

Posted by Karsten_ on 08 December 2013 - 02:39 PM

The Win32 API is going to outlive this Metro gimmick. The standard native windows API has outlived VB6, WPF, XNA, soon .NET and many more. Why should this recent (unsuccessful) locked down tablet platform be any different?

If Microsoft does ever drop Win32 (i.e likely only if they retire the Windows OS and potentially move over to Singularity/Midori), then the open-source Wine project will be more than happy to support all the many thousands of large commercial software that rely on it. Wine is not likely to ever support the locked down crud that is Metro.


#5112808 Viability of Java For Video Games

Posted by Karsten_ on 28 November 2013 - 12:09 PM

Java can be compiled to native machine code with GCJ, so then as long as you use the right libraries it would have the same performance as C++.


I don't think I have ever seen a game written in Java and compiled using GCJ. Probably because GCJ is not very actively developed and still only supports ~Java 1.4.

Either way, since standard Java will very likely need to be using native libraries to create a game (OpenGL, OpenAL, ODE, Bullet, etc..), the speed is very unlikely to be an issue since much of the processing is done by native code (in the .dll or .so) anyway.


#5112569 Where is the source for cout

Posted by Karsten_ on 27 November 2013 - 03:53 PM

It's interesting since AMD doesn't supports their hardware on FreeBSD AFAIK, so they're probably rolling some custom drivers too.

Yep, thats right, though interestingly since we have had no help in the form of binary drivers from AMD, the open-source radeon driver is actually pretty usable for 3D (almost on par with that in Linux). However, since Nvidia provides binary blobs for its hardware, the open-source "nv" is utter shite (nowhere near the usefulness of Linux's Nouveau).

 

Moral of the story, AMD has had to be cruel to be kind ;)

 

All I know is that if I was that skilled developer putting all that effort into developing a highly complex driver, it must be soul destroying to know that in ~5 years when the new console comes along, all your effort will be completely lost. I bet they would love to open-source their work and prove to the world that they are one of the rare breed of programmers, smart enough to be able to create something like that!

 

Edit: Thinking about it. I bet all AMD did was release the specs for their hardware to Sony and they did it all in house. Afterall, AMD's UNIX drivers are extremely low quality (no 2D acceleration for a start) which would be an issue for the PS4.




#5112487 Viability of Java For Video Games

Posted by Karsten_ on 27 November 2013 - 10:52 AM

I have some experience of using Java / OpenGL for Android development. It was fast enough but since the Java garbage collector does not extend to the graphics card buffers, I found it to be really fiddly to manage the memory manually.

C++ has RAII for memory management which works great with vertex buffers, textures etc.. whereas I found the Java code needed to be spammed with try catches. Java was not great here.

All in all, I suggest that unless you know that you have all the Java wrappers required to do your project, Java is fine. If you feel you may need to wrap native libraries, not only will you need to write the native side of the Jni layer in C/C++ anyway but you will be spending time writing bindings rather than games.

I recommend Java shim and the rest in C++ any day of the week smile.png


#5112469 Where is the source for cout

Posted by Karsten_ on 27 November 2013 - 09:19 AM

Clang's C++ compiler provides libc++[.so|.dll], GCC-C++ provides libstdc++ (I think), and other compilers provide their own standard C++ Library.

When using the C++ compiler, it links in the core c++ library implicitly. You can easily test this in GCC by compiling the .cxx files into object files (with -c) and then using ld as the linker rather than g++. This will then throw a fit and spam the console with linker error messages since the standard library is not linked (ld is a C linker when used with no parameters).

As for tracking down the exact declaration of std::cout... Good luck, C++ can be a nightmare to follow when overly used but reading standard library source code is something much worse ;).
Note that in many cases, the header files also have different implementations depending on the compiler, vendor or even standard library used. For example, OpenBSD has clang 3.2 and so does FreeBSD, however OpenBSD's clang uses a different C++ standard library (so doesnt support the full C++11 standard).


#5109450 Candy Crush type game in C

Posted by Karsten_ on 15 November 2013 - 07:37 AM

Possibly because

while(r=1)
is assigning 1 to r. Instead you might want to use:

while(r==1)



#5109325 How Languages Compare?

Posted by Karsten_ on 14 November 2013 - 06:47 PM

struct DeadPlayer {
     Player player;
     Point deathLocation;
}

Now, you write methods that take a DeadPlayer* as their first argument (and observe, you can pass DeadPlayer pointers to all methods that expect a Player).


Nice example.
Usually a fairly junior C# or Java developer will jeer at C because they don't realize or understand how this works. This is how Gtk+ (and many object-orientated C libraries) does it and demonstrates that C is pretty darn flexible.


#5109312 How Languages Compare?

Posted by Karsten_ on 14 November 2013 - 05:56 PM

Nowadays the trend in game development is to use the component entity system which works really nicely with languages like C which don't actively enforce rigid object orientation.

At work we tend to write fairly typical C code using similar patterns to Gtk+ for our small amount of object orientation but then we attach components to a single type akin to Unity's GameObject.
We do however use the GNU C++ compiler so we can access some of the really useful C++ functionality like std::string, std::vector, smart pointers etc. We also use external C++ and C libraries so using a C++ compiler was the most compatible choice.

Also, it seems easier to interface with C code from a Java or Objective-C shim layer (for mobile devices), than C++.

My personal favorite feature of C over C++ is that if you define the struct in the .c file and just have a forward declaration of the struct and corresponding functions in the .h file, it is much more encapsulated than even a class with everything private in C++ since other developers can't even see the data and you have complete control over any aspect of the data being exposed. This can't seem to be done so well in C++ without rewrapping all the functions because the class contains the functions so has to be exposed. Thus the pimpl idiom which I find a tad messy and convoluted.


#5107125 C++ (SFML) and Flash player/Unity

Posted by Karsten_ on 05 November 2013 - 04:08 AM

Ah good point, it is worth mentioning that Emscripten provides SDL 1.x (and soon SDL 2.0). However, since the emscripten version of the SDL API has been tweaked to run in a mobile browser (i.e touch events) and is already 3D accelerated, it is likely to stick around for many years to come (and will almost certainly still outlive commercial proprietary products like Unity).


#5106975 C++ (SFML) and Flash player/Unity

Posted by Karsten_ on 04 November 2013 - 02:00 PM

Whao, that's sounds amazing, i think it's the time to learn SDL. Thank you! smile.png


smile.png

Luckily SDL also has some fantastic tutorials written by GameDev.net's own LazyFoo (http://lazyfoo.net/SDL_tutorials/). These should help you get started. For 2D games it covers pretty much everything.

As an added bonus, when compiled with Emscripten, your SDL games will actually be hardware accelerated because they use the web browsers HTML5 canvas underneath.


#5106968 C++ (SFML) and Flash player/Unity

Posted by Karsten_ on 04 November 2013 - 01:34 PM

FlasCC unfortunately still targets the unportable proprietary Flash stage system.

Emscripten could be perfect here. It is basically a C++ to Javascript compiler but also provides well known C++ media libraries such as SDL, OpenGL, SDL_mixer, SDL_image, Qt, glut etc...

My software always uses either SDL or Glut and OpenGL so it has been very easy to put out a web build. I highly recommend these technologies if you want to keep with C++ but also target the web (as well as every other platform under the sun ;)

https://github.com/kripken/emscripten

A few simple demos using the technology can be found at http://devio.us/~kpedersen/mutiny/doku.php?id=demos (apologies for the slow server)


#5106880 Linking libraries in VS 2012 (Express)

Posted by Karsten_ on 04 November 2013 - 04:37 AM

We use the Microsoft C++ compiler in much the same way as GCC on Windows. The following is a few examples from our Makefiles if it helps (personally I find the documentation for commandline MSVC usage to be really lacking!).


.cpp unit to .obj
cl.exe /nologo /EHsc -c -I..\..\..\import\msvc\include -I..\..\ $(CXXFLAGS) /Fo$@ $<

relevant .obj files to static lib. Here we are also including the GLEW32s.lib into our static lib so it doesnt need to be linked in during the final step.
lib.exe /OUT:..\..\lib\mutiny.lib $(OBJ) ..\..\import\msvc\lib\GLEW32s.lib

Link other .obj files to final .exe and then link against required libs and our static lib we generated in the step above
link.exe /SUBSYSTEM:WINDOWS /OUT:$(BIN) $(OBJ) /LIBPATH:..\..\..\import\msvc\lib /LIBPATH:..\..\..\lib OpenGL32.lib GLU32.lib SDLmain.lib SDL.lib mutiny.lib $(LDFLAGS)

The main thing to notice is the /LIBPATH parameters are similar to -L on gcc. Also note that there is no need for -l, you just specify the name of the lib (including the .lib suffix).


#5102678 so i took one look at the sdl source code...

Posted by Karsten_ on 19 October 2013 - 12:39 PM

Take comfort in the knowledge that SDL is already written (and open-source) for you to always use rather than having to rewrite something similar yourself.

Also, using SDL with C and C++ is easy. Just like using .NET (C#) is easy whereas if you look through the source code of Mono (or shared source (rotar) versions of Microsoft's .NET) it is incredibly complex.

 

I tried porting Microsoft's .NET to a modern version of FreeBSD (it originally was created for Windows XP and FreeBSD 4.7). I got as far as the PAL abstraction layer before I started to get the shakes. Now I am writing games until I recover from the experience haha.




#5101332 Best way to showcase a game made in Python/Pygame

Posted by Karsten_ on 14 October 2013 - 11:35 AM

A website with pictures, an embedded video and downloadable 32bit Windows exes or perhaps an Android APK* of the game is usually your best bet.
This also has the added benefit of letting your viewers get a local copy of your game to pass around so not having to worry about internet streaming which is quite a benefit (whereas many web games need internet or a small local html server (like mongoosehttpd) to be provided). Or even worse, they need horrible web plugins**!

With Python, you might want to use a packaging system since Python isn't very common on Windows machines for a typical user. If you can modify your install of python to be portable, then you might have some luck creating a self extracting .exe using WinRAR.

Emscripten (C/C++ to Javascript) compiler can compile a Python interpreter so depending on what dependencies your game uses, you might be able to get it running on a webpage too.

* Android is the most common tablet OS (rivaling even that of desktop systems) and seeing as you are not trying to sell your showcase game (at this point in time) your viewers can sideload it without the faff of developer certificates from something like iOS or Metro.

** I am looking at you, Unity web player! Though the developers are currently working on a WebGL javascript exporter using Emscripten.




PARTNERS