Tag Info

Hot answers tagged

47

I have worked extensively with a pure-C game engine that has shipped several products, so it is absolutely possible. Here's my personal experience with working in both C vs C++ engines: Using pure-C structures allows you to take advantage of knowledge about the alignment of structures, and you can then use this information to build your object persistence ...


33

However, would writing an entire game engine in C be unreasonable today? It's reasonable, but the question is what does it buy you? You likely don't need the extreme portability C offers, and it's a shame to give up all of the features C++ offers unless you're really philosophically set against it. What are, if any, some advantages that C has over ...


22

The answer depends a bit on what you mean by "game", and on "used". I'll assume "used" means "written during the course of the specific game project". In my experience and anecdotal data from people I've talked to: in browser based games? None. in typical PC games? None. (But you might see some in low level libraries.) in iOS and Android games? None. ...


21

C++ does everything C does. You can trivially mix C and C++ in cases where the advantages of C outweigh those of C++. This is a very intentional design decision of C++. C++ does things that C does not. This includes easy polymorphism, but also easy compile time code generation via templates. This is really handy for things like containers, which are ...


19

The bulk of high performance code in modern console games is written using a sort of middle ground between assembly and C++: compiler intrinsics. These constructs look and parse like C++ functions, but are actually translated into single machine instructions. So, for example, my "clamp each value of vector V to be >= a and <= b" function looks like // ...


18

The simple answer is no, you do not want to use the glutIdleFunc callback in a game that has some sort of simulation. The reason for this is that this function divorces animation and draw code from window event handling but not asynchronously. In other words, receiving and handing window events stalls draw code (or whatever you put in this callback), this is ...


14

How I'd probably do it so I could maintain some art control and not potentially spend a long time trying to tweak a procedural method to get it just right... First, manually create a number of sprites of tea leaf clumps as your art "pool" - not each as an entire cup's worth of tea leaves, but more like a smaller grouping. Say, 20 of them or so? Then place ...


12

Yes and no. Officially, the only thing you can use on the 360 with XNA is C#. You can't ship any unmanaged DLLs with an app on xbox live, and if you want to write your game in C, you need a dev kit and an impossible-to-get contract with Redmond. That said, anything you can compile into CIL that will run on the compact framework will be okay. If you can ...


11

I am rewriting a 2D game engine written in C++ and Lua into C and Lua. So far the experience have been quite good. Obviously doing vector and matrix operations don't end up as nice looking in C. But apart from that I have found the experience quite refreshing after spending 10+ years as a C++ developer. C has a number of advantages over C++: The compiler ...


11

You can find the video memory of an Nvidia card using the NVX_gpu_memory_info extension, or an ATI card using ATI_meminfo. Here is a snippet of code I found which might get you started. However, Paul Nettle at flipcode wonders why one would want to find the available video memory, saying: The reason it's difficult (and sometimes impossible) to ...


11

Assuming... you are talking about converting to a buffer of bytes You are using UDP and performance is a concern Try to avoid wasting space in your packet for defining structure. I.E. send, at minimum, a byte to denote the type of packet, then just assume each packet received follows the predefined structure for that type of packet Should I just read ...


8

I will try to answer this as best as I can, but there are certain "best practices" which I am unsure on, but I'll try to break it down as cleanly as possible. FSMs Firstly, the Miner tutorial is from Programming Game AI by Example by Mat Buckland (which I do recommend you get as an introduction to AI). He uses an enum for each state, NOT a struct. With the ...


8

Some color data will be lost or changed regardless of your texture format. However, a bigger problem will be gamma correction. Gamma correction can be a tricky subject since your game will not appear visually the same across all display technologies and finding a single solution is not going to be easy. These might help you out: ...


8

Why at a certain point in time the industry switched massively to C++ ? What are the reasons for the choice that ID made ? Id Software is not "the industry". They are one company. While they may be influential, they aren't everyone. I've worked on a couple of game engines that date back to 1999, and they used C++. The principle reasons for the ...


8

Your problem is the order in which you specify your vertices and texture coordinates: glVertex3f(0, 0, 0); glTexCoord2f(0.0, 0.0); should be: glTexCoord2f(0.0, 0.0); glVertex3f(0, 0, 0); OpenGL is a state machine, and in immediate mode, whenever you call glVertex3f the vertex will take on the different attributes (color, texture coordinates, etc.) ...


8

You are looking for a scripting language that can be embedded into your application. That is, a language which is designed to be interpreted at runtime (in many cases quite efficiently) and can be used to allow user extension of your native code written in C/C++/ObjC. There are many to choose from. Lua and Python are two quite popular ones, particularly ...


8

Sure you can, it's just not trivial to get it sounding "nice". I don't know how to do it in Linux, but if you can play a PCM buffer, all you have to do is fill it with whatever you want. So supposing your buffer is set to play in monaural, signed 16-bit samples, at 44100 samples per second, creating a pure (sinusoidal) A4 sound (440 Hz) is as simple as ...


8

You could think of individual places as "rooms" with "doors" connecting them: To implement this, you could create a struct Room to hold a room, with fields for a set of items currently in it and what directions its exits lie in. Then simply keep an array of all rooms and have a pointer to the one the player is currently in. There are ways of getting ...


8

Intel's compiler is just a different compiler. GCC++ and VC++ produce production quality code, just as well as Intel's ICC does. The main difference lies in 4 key areas: a) Features supported (mostly differing on C++11 features) b) Executable size c) Runtime d) Compile time When you're trying to squeeze every last bit of performance out of (mostly) ...


8

Many non-PC platforms, including some consoles and handhelds, use a modified GCC as their primary/only compiler. On the PC, most game dev houses just use Visual Studio's compiler. The choice of compiler typically has little impact on runtime speed compared to engine design and graphics, they all paid for Visual Studio anyway due to its feature set as an ...


7

First off, you shouldn't be using GLUT for anything but testing. As far as I know, GLUT was never meant for application development. I recommend picking up SDL or SFML instead. That said, implementing framerate-independent rendering is relatively simple. // global gLastTick contains the last processed tick (ms) // game loop int tick = ...


7

You can write a game engine in practically any language using practically any methods of rendering. You could write a game engine in bash using console output for example. So, I think it would be best to define what exactly you want to learn in writing your own engine. There are a lot of "fields" in game development. Core Game Engine Rendering / ...


7

Try perlin noise with a binary cutoff value of 0.8 or so? Uploaded example image to http://imgur.com/a/Ydc4y . The first is the second image with a threshold applied. The second is basic perlin noise, for which you can find multiple good references such as http://en.wikipedia.org/wiki/Perlin_noise and ...


7

You haven't set a diffuse colour for your light (via glMatrialfv (GL_DIFFUSE, ...) and - according to the GL spec - the default diffuse colour is {0.8, 0.8, 0.8, 1.0} - i.e. light grey. You also haven't set an ambient colour (default {0.2, 0.2, 0.2, 1.0} - dark grey). The default behaviour of lighting is that it multiplies by the current colour, so with an ...


6

OpenGL and freeglut will do what you're looking for. Freeglut can create the spheres, cubes, cylinder, cone, donuts, teapots, etc. GLUT (and hence freeglut) allows the user to create and manage windows containing OpenGL contexts on a wide range of platforms and also read the mouse, keyboard and joystick functions. http://freeglut.sourceforge.net/


6

The "normalized" parameter affects the use of fixed point values. This doc says the parameter "Specifies whether fixed-point data values should be normalized (GL_TRUE) or converted directly as fixed-point values (GL_FALSE) when they are accessed." Further, this one states "For glVertexAttribPointer, if normalized is set to GL_TRUE, it indicates that values ...


6

How to create prerendered effect is another question. You can create fires, smoke etc in Autodesk Maya. It has very strong fluid solver (fluids means fire, smoke, nebulas or even fog ...). This can be also putted into sequence of files and played. For real smoke/fire etc. simulation, you can implement physically correct (or very near to it) fluid solver is ...


6

Your guess is basically correct, and it's being done as an optimization (most likely; I can only speculate of course as I did not write the code). While an application in Windows appears to have full access to the entire range of RAM in the machine (or at least the range reported to it by the OS), in practice the OS is virtualizing an application's access ...


5

Fabien Sanglard has written an article about his 3d engine in C. On reddit, this article has created an interesting debate. http://fabiensanglard.net/c/ http://www.reddit.com/r/gamedev/comments/ctiqm/iphone_3d_engine_experience_from_2009_especially/ Languages are only tools... So use them wisely. To create a good game, it can be easier to use XNA or ...



Only top voted, non community-wiki answers of a minimum length are eligible