现在的位置: 首页 > 综合 > 正文

graphics shaders 2 :opengl new vs comparitable

2018年05月27日 ⁄ 综合 ⁄ 共 1579字 ⁄ 字号 评论关闭

Standard OpenGL Function                  Built-in Attribute Variable 
glVertex*(...) gl_Vertex
glColor*(...) gl_Color
glNormal*(...) gl_Normal 

glMultiTexCoord*(i, ...) gl_MultiTexCoordi, i=1..N 

Attribute Variables in Compatibility Mode:

attribute vec4 gl_Color;;
attribute vec3 gl_Normal;
attribute vec4 gl_Vertex;
attribute vec4 gl_MultiTexCoord0;

Uniform Variables in Compatibility Mode
In compatibility mode, GLSL defines a number of built-in uniform variables that
give you access to OpenGL states for primitives, as we describe fully in Chapter 5
on the GLSL language. There are a number of built-in uniform variables, including
the ModelView, Projection, and Normal matrices and all texture, light, and materials
data. Your applications set these values through standard OpenGL functions and can
use the associated uniform variables in your shaders. These give you access to all the
OpenGL state values or values derived from these states. When a program object is
made current, the built-in uniform variables that track the OpenGL state are initialized
to the current value of those states, and any later OpenGL calls that modify state values
update the built-in uniform variable that tracks those states. The most commonly-used
of these are shown in Table 3.1

Standard OpenGL Function Built-in Uniform Variable
transformations mat4 gl_ModelViewMatrix
mat4 gl_ModelViewProjectionMatrix
mat4 gl_ProjectionMatrix
mat3 gl_NormalMatrix
materials struct gl_MaterialParameters {
vec4 emission;
vec4 ambient;
vec4 diffuse;
vec4 specular;
float shininess;
} gl_Frontmaterial; gl_BackMaterial;
lights struct gl_LightSourceParameters {
vec4 ambient;
vec4 diffuse;
vec4 specular;
vec4 position;
vec4 halfVector;
vec3 spotDirection;
float spotExponent;
float spotCutoff;
float spotCosCutoff;
} gl_LightSource[gl_MaxLights];

抱歉!评论已关闭.