Autocomplete works just fine but it is very hard to use with enums and other constants…
Here is what I mean…
This is from Render.cpp
[code]void Renderer::SetShadowQuality(int quality)
{
if (!graphics_)
return;
quality &= SHADOWQUALITY_HIGH_24BIT;
// If no hardware PCF, do not allow to select one-sample quality
if (!graphics_->GetHardwareShadowSupport())
quality |= SHADOWQUALITY_HIGH_16BIT;
if (!graphics_->GetHiresShadowMapFormat())
quality &= SHADOWQUALITY_HIGH_16BIT;
if (quality != shadowQuality_)
{
shadowQuality_ = quality;
shadersDirty_ = true;
ResetShadowMaps();
}
}[/code]
Here is one example of the function being called from Engine.cpp
...
renderer->SetDrawShadows(GetParameter(parameters, "Shadows", true).GetBool());
if (renderer->GetDrawShadows() && GetParameter(parameters, "LowQualityShadows", false).GetBool())
renderer->SetShadowQuality(SHADOWQUALITY_LOW_16BIT);
renderer->SetMaterialQuality(GetParameter(parameters, "MaterialQuality", QUALITY_HIGH).GetInt());
renderer->SetTextureQuality(GetParameter(parameters, "TextureQuality", QUALITY_HIGH).GetInt());
...
Because the definition accepts an int it is not clear what is supposed to be passed into “SetShadowQuality”.
If I start typing “quality” in an ide it won’t list “SHADOWQUALITY_LOW_16BIT”…
So to use enums you need to remember the exact name of everything…
This is really frustrating when I don’t know what the function wants to be input as the int.
I then have to grep the entire Urho3D source and find an example where the constant was used in the function.
With one of the constants now I then grep the entire source again and find where all of the constants were defined and find
the name of the constant value that I am looking for…
This takes a lot of time.
Here is another snip from GraphicsDefs.h:
/// Texture units.
enum TextureUnit
{
TU_DIFFUSE = 0,
TU_ALBEDOBUFFER = 0,
TU_NORMAL = 1,
TU_NORMALBUFFER = 1,
TU_SPECULAR = 2,
TU_EMISSIVE = 3,
TU_ENVIRONMENT = 4,
#ifdef DESKTOP_GRAPHICS
TU_VOLUMEMAP = 5,
TU_CUSTOM1 = 6,
TU_CUSTOM2 = 7,
TU_LIGHTRAMP = 8,
TU_LIGHTSHAPE = 9,
TU_SHADOWMAP = 10,
TU_FACESELECT = 11,
TU_INDIRECTION = 12,
TU_DEPTHBUFFER = 13,
TU_LIGHTBUFFER = 14,
TU_ZONE = 15,
MAX_MATERIAL_TEXTURE_UNITS = 8,
MAX_TEXTURE_UNITS = 16
#else
TU_LIGHTRAMP = 5,
TU_LIGHTSHAPE = 6,
TU_SHADOWMAP = 7,
MAX_MATERIAL_TEXTURE_UNITS = 5,
MAX_TEXTURE_UNITS = 8
#endif
};
This is useful.
If I have some func:
int Foo(TextureUnit textureUnit)
{
/// Do somthing
}
I can just type “Foo(TU_” and most of the possible values are listed.
Here is an example where this isn’t done in GraphicsDefs.h:
enum RenderSurfaceUpdateMode
{
SURFACE_MANUALUPDATE = 0,
SURFACE_UPDATEVISIBLE,
SURFACE_UPDATEALWAYS
};
Here instead of following the camelcase the it just uses “SURFACE_” This seems really inconsistent to me.
I think camelcase enums like TextureUnit’s should be used everywhere for consistency. Including constants that are treated as enums. I hope I made sense. :\