Difference between revisions of "Technical Documentation"

From Unvanquished
Jump to: navigation, search
(Publications: Fix closing tag location)
(Begin creating a listing of all file formats read by the engine)
Line 54: Line 54:
Daemon uses Neil "haste" Toronto's [http://www.ra.is/unlagged/ Unlagged mod].
Daemon uses Neil "haste" Toronto's [http://www.ra.is/unlagged/ Unlagged mod].
==Data Files==
Daemon uses a variety of file formats. Many of these formats are custom. <!-- just try and provide a dump of all configuration files, then I'll reorganize them -->
* Bot behavior trees
* Player configuration files
** Crosshair configuration
** Pubkey
* Server configuration files
** [[Map_layouts|Map layouts]]
* Particle & trail system files
* Sound configurations
** [[Music_and_sounds#Buildables|Buildables]]
* Model data ([[Exporting_Models#What_is_MD5.3F|discussion of supported formats]])
** Skins
** [[Exporting_Models#MD3_3|MD3 animation configuration files]] &mdash; specify which frames are for which animations
** Configuration files
*** [[Exporting_Models#Buildables_2|Buildables]]
*** [[Exporting_Models#Weapons_2|Weapons]]
*** [[Exporting_Models#Player_models_2|Player models]]
* Map data
** Map geometry (BSPs)
** Color grading configurations
==Game logic==
==Game logic==

Revision as of 13:27, 15 April 2013

Currently, this page isn't of much help, but you can change that by editing it!


The following branches are under active development and may be of interest:

  • librocket — Work to integrate libRocket is being done on this branch. libRocket is a library that will allow us to create user interfaces using dialects of HTML and CSS.
  • bots2 — New bot code, using behavior trees.

Language Oddities

  • You must use the INLINE macro instead of inline.
  • You must cast integers that are being used as enum values to an enum type. For example:
    BG_Class ( ( class_t ) self->client->ps.stats[ STAT_CLASS ] )

Source code & data structure

  • main/ Data associated with the game.
    • def/ Entity definitions for Radiant.
    • fonts/
    • gfx/
    • glsl/ OpenGL shader code.
    • lights/
    • models/
    • scripts/
    • sound/
    • translation/
    • ui/
  • src/
    • engine/ Engine source code.
      • asm/
      • client/
      • null/
      • qcommon/
      • renderer/ Vanilla (fixed-function pipeline) renderer
      • rendererGL/ Modern XReal-based renderer
      • server/
      • sys/
    • gamelogic/ Code that falls outside the scope of the core engine. These are all run in separate virtual machines.
      • cgame/ Client-side game code.
      • game/ Server-side game code.
      • ui/ User interface code.

Program entry point

The main function may be found at around line 591 of src/engine/sys/sys_main.c. Note that some magic happens on the Mac in src/engine/sys/SDLMain.m.

Lag compensation

Daemon uses Neil "haste" Toronto's Unlagged mod.

Data Files

Daemon uses a variety of file formats. Many of these formats are custom.

Game logic

Buildable information is encapsulated in the cg_buildables array (declared in src/gamelogic/cgame/cg_main.c)

Constants used to define gamelogic variables are in src/gamelogic/game/tremulous.h.


  • buildableInfo_t — Encapsulates data associated with buildables (sounds, animations, etc.).
  • buildable_t — An enumeration of all buildable types.
  • buildableAttributes_t — Encapsulates gameplay information associated with buildables. There is an array of these called bg_buildableList.


Server game state initialization occurs in G_InitGame() in src/gamelogic/game/g_main.c.

Particle & trail system

For now, please see the Tremulous documentation.

GL3 Renderer

This section is a work-in-progress.

Source code for the OpenGL 3 renderer is located in src/engine/rendererGL.

Shaders are implemented as subclasses of the GLShader class. All are defined in src/engine/rendererGL/gl_shader.h.

Compiled GLSL shader files (located in the hard-coded location "glsl/" with the .bin filename extension) are read by GLShader::LoadShaderBinary().

All possible parameters (what OpenGL calls "uniform variables") that may be passed to a shader are enumerated in the shaderProgram_t structure in src/engine/rendererGL/tr_local.h.

Shaders with duplicate functionality is achieved with multiple inheritance. E.g., gl_genericShader is of type GLShader_generic* which derives from the following classes:

  • GLShader
  • u_ColorMap
  • u_ColorTextureMatrix
  • u_ViewOrigin
  • u_AlphaTest
  • u_ModelMatrix
  • u_ModelViewProjectionMatrix
  • u_ColorModulate
  • u_Color
  • u_BoneMatrix
  • u_VertexInterpolation
  • u_PortalPlane
  • GLDeformStage

GLSL shaders may be found in main/glsl/. Please see the full article for a complete listing.

Helper classes

As mentioned above, shader classes make use of multiple inheritance to give them the relevant methods for controlling their behavior.

Uniform variables

Uniform variables are controlled with classes with the u_ prefix:

  • u_BoneMatrix — Provides the convenience method SetUniform_BoneMatrix.

Compile macros

  • GLCompileMacro_TWOSIDED
  • GLCompileMacro_EYE_OUTSIDE
  • GLCompileMacro_USE_SHADOWING
  • GLCompileMacro_USE_GBUFFER


Mac OS X users with XCode installed can access OpenGL man pages via the terminal.

Alternatively, OpenGL API reference documentation is available online:

Valgrind and fglrx

fglrx drivers cause Valgrind to spew out a lot of false errors. You can suppress these by using the --suppressions=/path/to/file.supp flag. You must pass the full path (no use of the tilde symbol). The following file can be used as a template for your suppression file. Keep in mind that the location of the fglrx library may need to be changed.



General Game Development