Changes between Version 37 and Version 38 of Coding_Conventions
- Timestamp:
- May 8, 2018, 10:21:38 PM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Coding_Conventions
v37 v38 407 407 == GLSL == 408 408 * Use the same basic formatting as described above for C++. 409 * Use lowerCamelCase for names: 410 {{{ 411 #!glsl 412 // Bad 413 vec2 local_position; 414 mat4 CalculateInvertMatrix(...); 415 int _pixelcounter; 416 417 // Good 418 vec2 localPosition; 419 mat4 calculateInvertMatrix(...); 420 int pixelCounter; 421 }}} 409 422 * File extensions for shaders: 410 * .fs- fragment shader411 * .vs- vertex shader412 * .gs- geometry shader413 * .cs- compute shader423 * `.fs` - fragment shader 424 * `.vs` - vertex shader 425 * `.gs` - geometry shader 426 * `.cs` - compute shader 414 427 * All GLSL files should start with right [[https://www.khronos.org/opengl/wiki/Core_Language_(GLSL)#Version|version]]. 415 428 {{{ 416 #! cpp429 #!glsl 417 430 #version 120 418 431 }}} 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 437 vec4 a; 438 vec2 b; 439 440 // Simple assign. 441 a.x = b.x; 442 a.y = b.z; 443 444 // Assign with swizzle mask. 445 a = 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 449 uniform mat4 u_invertTransform; 450 451 varying vec2 v_uv; 452 453 attribute vec3 a_normal; 454 }}}