Hacking Gluon

Please note: This section of the documentation is for people who wish to hack on Gluon itself. If you wish to create games using Gluon, this is not where you want to be looking, as it details the internals of the Gluon libraries. Instead, please head on over to the Gluon Creator and Game Logic sections to learn about game creation using Gluon.

Introduction

If you wish to work on the code base of Gluon itself, be sure to get the latest code from git. Following the instructions on the download the source and installation pages should get you setup completely. Fellowing guides may be useful to read if you do not know the area of expertise:

http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Table-of-Contents.html for OpenGL

http://www.cplusplus.com/doc/tutorial/ for C++

http://connect.creativelabs.com/openal/Documentation/OpenAL_Programmers_Guide.pdf for OpenAL

http://doc.qt.nokia.com/tutorial.html for Qt

It is slightly different in our case, but here you can find some good tips about submitting patches: http://git.kernel.org/?p=git/git.git;a=blob;f=Documentation/SubmittingPatches;h=938eccf2a5ac9dd629be1bc6bb53a59723c99083;hb=HEAD

The following describes coding style and other information bits of code related information for Gluon. If anything is unclear, we suggest reading the KDELibs ( http://techbase.kde.org/Policies/Kdelibs_Coding_Style ) guidelines, which contain many good items on this topic. (However, we have our own set of rules, different than those of KDELibs, see below).

Setting up KDevelop

(This section still need info about this kde prefix thing that I dont know about) First you have to install Kdevelop via your package manager. After launching kdevelop you can import the code from Project->Open/Import project and then finde the Makefile there is at the root of Gluon repo. Remeber to set "-DCMAKE_INSTALL_PREFIX=`kde4-config --prefix`" under "installation prefix

Now you can compile Gluon by pressing "Build Selection" in the upper left corner. In order to run gluon from within KDevelop you need to configure the launcher. Go to Run->Configure Launcher. At "project target" you simple have to write "creator/gluoncreator" and press OK. Now you can launch it via pressing the button "Execute".

Headers

The license header in all source files should be as follows:

/*
 * This file is part of the Gluon Development Platform
 * Copyright (C) year  name of author
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

Please replace the copyright line as appropriate (if there are multiple authors for one file, please add a separate line for each person).

Code Style

The following is a code-style-by-example section. Please note how in particular return types, super-type constructors, block brackets and shorthand are used:

Note that this example uses 4 spaces for indentation, as all code within Gluon should.

source.h

#include "gluonobject.h"

namespace Component
{
    class SomeClassPrivate;
    /**
     * A short description of Some Class which stops after the first newline or after this period.
     * This is a continued description of the class.
     */
    class SomeClass : public GluonCore::GluonObject
    {
        Q_OBJECT
        Q_PROPERTY(QString someProperty READ someProperty WRITE setSomeProperty)
        GLUON_OBJECT(Component::SomeClass)
    
        public:
            /**
             * A constructor.
             * A longer description of the constructor
             *
             * @param parent A description of the parent
             */

            SomeClass(const QObject * parent = 0);
            /**
             * A destructor.
             * A longer description of the destructor
             */
            ~SomeClass();
            
            /**
             * The getter for the someProperty property
             *
             * @return A string containing the value of the property someProperty
             */
            QString someProperty() const;

            /**
             * Setter for the someProperty property
             *
             * @param newSomeProperty The new value for someProperty
             */
            void setSomeProperty(const QString &newSomeProperty);
            
        private:
            /**
             * The only private item in the class. All other private
             * data should be contained in this class. See also
             * google for information on the pimpl design pattern.
             */
            SomeClassPrivate * const d;
    };
}

source.cpp

#include "source.h"

#include <QtCore/QString>

REGISTER_OBJECTTYPE(Component,SomeClass)

namespace Component
{
    class SomeClassPrivate
    {
        public:
            SomeClassPrivate() {}
            ~SomeClassPrivate() {}
            
            QString someProperty;
    }
}

using namespace Component;

SomeClass::SomeClass(const QObject * parent)
    : GluonObject(parent),
      d(new SomeClassPrivate)
{
    // A convoluted bit showing how multi-line blocks should look
    // This would of course be done better with QString::repeated()
    for(int i = 0; i &lt; 10; ++i)
    {
        someProperty = "ab";
        // Use the GluonObject debug() function to show debug output in Creator
        debug( QString("Current value of someProperty: %1").arg(someProperty) );
    }
}

SomeClass::~SomeClass()
{
    delete d;
}

void
SomeClass::setSomeProperty(const QString &amp;newSomeProperty)
{
    // This is a convoluted check to show how an single-line block should look
    if(!newSomeProperty.isEmpty)
        d->someProperty = newSomeProperty;
}

QString
SomeClass::someProperty() const
{
    return d->someProperty;
}

#include "someclass.moc"

Nightly Builds

Nightly builds can be found on this page: http://my.cdash.org/index.php?project=Gluon

Feel free to send patch(es) in case of warnings/errors you see there, if any. :-)

Todo List

Current tasks for Gluon