利用者:Jwilkins/VFX/Usage

提供: wiki
< 利用者:Jwilkins‎ | VFX
2013年9月24日 (火) 09:18時点におけるwiki>Jwilkinsによる版 (Source Code Conventions)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

This is rather rough atm.

OpenGL State Policy

Default BlendFunc is SRC_ALPHA, ONE_MINUS_SRC_ALPHA

Default for the BLEND bit is disabled.

Default for ShadeModel is FLAT (In ES/Core this refers only to the aspect state)

Default TEXTURE_2D is disabled. (In ES/Core this means that a shader that does not use samplers will be bound)

Assume this state if that is what you need to use. If you need to change it, then change it back when done or when calling other functions that assume the default.

The values of all PixelLoad and PixelStore are the same as OpenGL defaults (provide table) and should always be restored if they are different.

For DrawPixels, PixelLoad should be wrapped by the PIXEL aspect and the gpuPixelFormat function should be used.

For Tex*Image*, PixelStore should assume the defaults and reset defaults when pixel storing is completed.

ALPHA_TEST is disabled by default (In ES/Core this means the default current shader will have alpha testing disabled)

The default LIGHT_MODEL_TWO_SIDED is FALSE (In ES/Core this means that the basic shader doesn't flip the normal. In addition, the materials of the front and back are always changed in tandem and never differ, at least for the common light shader)

This may change but, the GPU_ASPECT_BASIC is the default aspect (This may change to there being no aspect selected, which would trigger a GPU_SAFETY violation if drawing was attempted)

The SCISSOR_TEST is enabled by default.

the default specular and diffuse material is white

The currently bound texture object is considered undefined (defaultless), so it needs to be set before any texturing

The current color and normal are considered undefined (defaultless), so they need to be set to the desired value before drawing

COLOR_MATERIAL is always enabled and is set to DIFFUSE (In ES/Core this means that shaders always use the current color attribute)

The TEXTURE_ENV_MODE for any texture object is always MODULATE (In ES/Core this means that shaders always multiple the color attribute by the texture sample, unless the aspect's semantics simply ignore color)

blender doesn't use ambient reflection at all, it is as if ambient is always black

glreport.y tool

These are guidelines meant to make everybody's job easier. If you need to bend them then bend away. If you need to break them then clean up your mess and then see if you can fix it. If this makes you job harder then we are doing it wrong.

No identifier in Blender's source code is allowed to have a name that follows the same conventions as those in OpenGL or popular OpenGL libraries.

  • Those kinds of tokens will be detected by glreport.py as reported as "Unrecognized Tokens"
  • The tool could be written to ignore comments, but just because something is in a comment doesn't mean it should be sloppy :-)
  • In comments avoid creating a false alarm by:
    • Delete the comment if it is not needed. Seriously, comments are often wrong and say what the code already says.
    • Using the proper name of an OpenGL function instead of abbreviating it (e.g., write 'glVertex3f' instead of 'glVertex')
    • Remove the functions prefix if the context makes it safe (e.g., write 'We use LightParameter here, but it has been deprecated...')
    • Write more generally (e.g., "OpenGL stipple pattern definitions" instead of "glStipple stuff")
  • The report tool does not look for indentifiers that end in _gl, however it is probably best to reserve these identifiers for functions that are directly related to using OpenGL.
    • A function that draws a duck should not be named 'draw_duck_gl' merely because it uses OpenGL to draw the duck (unless, perhaps, there was another function called draw_duck_dx. context is important).
    • A function that detects OpenGL extensions and chooses between alternative implementations of say, how to draw off screen objects, could be justifiably named 'setup_framebuffer_api_gl'

GLU should not be used except in stand alone example and test programs.

Source Code Conventions

Do not include glew.h directly, include GPU_glew.h so that everything gets patched in. It fills in missing symbols that are needed to compile with ES

In CMake, GL_DEFINITIONS is set instead of any particular option like -DGLEW_STATIC

Extension Wrapper - gpu_*

If a non _EXT or _ARB version of a symbol exists in glew then favor using it.

GPU_PROFILE_*

current_common is a way to tell if a shader is active and can be used in certain places to switch between core and compatibility mode. there is a pattern to using it

//-V112 tells ... to ignore the use of a magic number, particularly the number 4

capitalize hex colors