void GL_APIENTRY DebugMessageControlKHR(GLenum source,
                                        GLenum type,
                                        GLenum severity,
                                        GLsizei count,
                                        const GLuint *ids,
                                        GLboolean enabled)
{
    EVENT(
        "(GLenum source = 0x%X, GLenum type = 0x%X, GLenum severity = 0x%X, GLsizei count = %d, "
        "GLint *ids = 0x%0.8p, GLboolean enabled = %d)",
        source, type, severity, count, ids, enabled);

    Context *context = GetValidGlobalContext();
    if (context)
    {
        if (!ValidateDebugMessageControlKHR(context, source, type, severity, count, ids, enabled))
        {
            return;
        }

        std::vector<GLuint> idVector(ids, ids + count);
        context->getState().getDebug().setMessageControl(
            source, type, severity, std::move(idVector), (enabled != GL_FALSE));
    }
}
PlanetSektor::PlanetSektor(Vector3Unit position, Unit radius, SektorID id, Sektor* parent)
: Sektor(position, radius, id, parent), mSphericalShaderForSubPlanet(NULL), mTheta(0.0f)
{
    mType = PLANET;
    
    mSphericalShaderForSubPlanet = ShaderManager::Instance().getShader("sphere.vert", "sphere.frag");
        
    noise::module::Perlin p;
    if(id.count) p.SetSeed(id.count);
    DRVector3 idVector(id.x, id.y, id.z);
    idVector /= SHRT_MAX;
    setSektorSeed();
    
    const DRReal lacunarityMax = 2.4f;
    const DRReal lacunarityMin = 1.6f;
    
    // init values for planet perlin noise
    // Frequency of the planet's continents.  Higher frequency produces smaller,
    // more numerous continents.  This value is measured in radians.
	mPlanetNoiseParameters.continentFrequenzy = DRRandom::rReal(PI, PI/4.0f);
    
    // Lacunarity of the planet's continents.  Changing this value produces
    // slightly different continents.  For the best results, this value should
    // be random, but close to 2.0.
    mPlanetNoiseParameters.continentLacunarity = DRRandom::rReal(lacunarityMax, lacunarityMin);
    
    // Lacunarity of the planet's mountains.  Changing this value produces
    // slightly different mountains.  For the best results, this value should
    // be random, but close to 2.0.
    mPlanetNoiseParameters.mountainLacunarity = DRRandom::rReal(lacunarityMax, lacunarityMin);
    
    // Lacunarity of the planet's hills.  Changing this value produces slightly
    // different hills.  For the best results, this value should be random, but
    // close to 2.0.
    mPlanetNoiseParameters.hillsLacunarity = DRRandom::rReal(lacunarityMax, lacunarityMin);
    
    
    // Lacunarity of the planet's plains.  Changing this value produces slightly
    // different plains.  For the best results, this value should be random, but
    // close to 2.0.
    mPlanetNoiseParameters.plainsLacunarity = DRRandom::rReal(lacunarityMax, lacunarityMin);
    
    // Lacunarity of the planet's badlands.  Changing this value produces
    // slightly different badlands.  For the best results, this value should be
    // random, but close to 2.0.
    mPlanetNoiseParameters.badlandsLacunarity = DRRandom::rReal(lacunarityMax, lacunarityMin);
    
    
    // Specifies the amount of "glaciation" on the mountains.  This value
    // should be close to 1.0 and greater than 1.0. (1.375)
    mPlanetNoiseParameters.mountainGlaciation = DRRandom::rReal(1.6f, 1.01f);
 
    // Specifies the planet's sea level.  This value must be between -1.0
    // (minimum planet elevation) and +1.0 (maximum planet elevation.)
    const DRReal SEA_LEVEL = DRRandom::rReal(0.2f, -0.2f);
    mPlanetNoiseParameters.seaLevel = SEA_LEVEL;
    
    // Specifies the level on the planet in which continental shelves appear.
    // This value must be between -1.0 (minimum planet elevation) and +1.0
    // (maximum planet elevation), and must be less than SEA_LEVEL. (-0.375)
    mPlanetNoiseParameters.shelfLevel = DRRandom::rReal(SEA_LEVEL-0.01f, -0.8f);
    
    // Determines the amount of mountainous terrain that appears on the
    // planet.  Values range from 0.0 (no mountains) to 1.0 (all terrain is
    // covered in mountains).  Mountainous terrain will overlap hilly terrain.
    // Because the badlands terrain may overlap parts of the mountainous
    // terrain, setting MOUNTAINS_AMOUNT to 1.0 may not completely cover the
    // terrain in mountains.
    const DRReal MOUNTAINS_AMOUNT = DRRandom::rReal(0.9f, 0.1f);
    mPlanetNoiseParameters.mountainAmount = MOUNTAINS_AMOUNT;
  
    // Determines the amount of hilly terrain that appears on the planet.
    // Values range from 0.0 (no hills) to 1.0 (all terrain is covered in
    // hills).  This value must be less than MOUNTAINS_AMOUNT.  Because the
    // mountainous terrain will overlap parts of the hilly terrain, and
    // the badlands terrain may overlap parts of the hilly terrain, setting
    // HILLS_AMOUNT to 1.0 may not completely cover the terrain in hills.
    mPlanetNoiseParameters.hillsAmount = (1.0f + MOUNTAINS_AMOUNT) / 2.0f;
    
    // Determines the amount of badlands terrain that covers the planet.
    // Values range from 0.0 (no badlands) to 1.0 (all terrain is covered in
    // badlands.)  Badlands terrain will overlap any other type of terrain. (0.03125)
    mPlanetNoiseParameters.badlandsAmount = DRRandom::rReal(0.75f, 0.1f);
    
    // Maximum depth of the rivers, in planetary elevation units. (0.0234375f)
    mPlanetNoiseParameters.riverDeapth = DRRandom::rReal(0.02f, 0.0f);
    
    // Scaling to apply to the base continent elevations, in planetary elevation
    // units.
    mPlanetNoiseParameters.continentHeightScale = (1.0f - SEA_LEVEL) / 4.0f;
    
    // Calculate the sea level, in meters.
    DRReal MAX_ELEV = 1.0f; DRReal MIN_ELEV = -1.0f;
    DRReal seaLevelInMeters = (((SEA_LEVEL + 1.0f) / 2.0f)
    * (MAX_ELEV - MIN_ELEV)) + MIN_ELEV;
    mPlanetNoiseParameters.seaLevelInMetres = seaLevelInMeters;
    
    mPlanetNoiseParameters.maxHeightInPercent = DRRandom::rReal(0.005f, 0.001f);
    mPlanetNoiseParameters.minHeightInPercent = DRRandom::rReal(0.003f, 0.001f);
    
    // Offset to apply to the terrain type definition.  Low values (< 1.0) cause
    // the rough areas to appear only at high elevations.  High values (> 2.0)
    // cause the rough areas to appear at any elevation.  The percentage of
    // rough areas on the planet are independent of this value.
    mPlanetNoiseParameters.terrainOffset = DRRandom::rReal(0.8f, 2.4f);
    
    // Specifies the "twistiness" of the mountains.
    mPlanetNoiseParameters.mountainsTwist = DRRandom::rReal(0.75f, 1.25f);

    // Specifies the "twistiness" of the hills.
    mPlanetNoiseParameters.hillsTwist = DRRandom::rReal(0.75f, 1.25f);

    // Specifies the "twistiness" of the badlands.
    mPlanetNoiseParameters.badlandsTwist = DRRandom::rReal(0.75f, 1.25f);

    
    mPlanetNoiseParameters.print(true);
    
    mRenderer = new RenderPlanet(id, getSektorPathName(), &mPlanetNoiseParameters);
}