Changes between Version 37 and Version 38 of Coding_Conventions


Ignore:
Timestamp:
May 8, 2018, 10:21:38 PM (6 years ago)
Author:
Vladislav Belov
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Coding_Conventions

    v37 v38  
    407407== GLSL ==
    408408 * Use the same basic formatting as described above for C++.
     409 * Use lowerCamelCase for names:
     410{{{
     411#!glsl
     412// Bad
     413vec2 local_position;
     414mat4 CalculateInvertMatrix(...);
     415int _pixelcounter;
     416
     417// Good
     418vec2 localPosition;
     419mat4 calculateInvertMatrix(...);
     420int pixelCounter;
     421}}}
    409422 * File extensions for shaders:
    410     * .fs - fragment shader
    411     * .vs - vertex shader
    412     * .gs - geometry shader
    413     * .cs - compute shader
     423    * `.fs` - fragment shader
     424    * `.vs` - vertex shader
     425    * `.gs` - geometry shader
     426    * `.cs` - compute shader
    414427 * All GLSL files should start with right [[https://www.khronos.org/opengl/wiki/Core_Language_(GLSL)#Version|version]].
    415428{{{
    416 #!cpp
     429#!glsl
    417430#version 120
    418431}}}
    419  * Prefer to use own uniforms instead of built-in
     432 * Prefer to use own uniforms instead of built-in (`gl_ProjectionMatrix`, `gl_ModelViewProjectionMatrix`, etc).
     433 * Strictly follow specifications for the selected version. Some drivers ignore errors, that can fail others.
     434 * Prefer to use swizzle masks:
     435{{{
     436#!glsl
     437vec4 a;
     438vec2 b;
     439
     440// Simple assign.
     441a.x = b.x;
     442a.y = b.z;
     443
     444// Assign with swizzle mask.
     445a = b.xz;
     446}}}
     447 * Prefer to use prefixes for global variables to distinguish them: `a_` - for attributes, `v_` for varyings, `u_` - for uniforms.
     448{{{#!glsl
     449uniform mat4 u_invertTransform;
     450
     451varying vec2 v_uv;
     452
     453attribute vec3 a_normal;
     454}}}