Function #
Buffer #
- glClearBuffer
void glClearBufferfv (GLenum buffer, GLint drawBuffer, const GLfloat *value);
clear
buffer
ofdrawBuffer
withvalue
Shader & Program object manage #
- glCreateShader
GLuint glCreateShader (GLenum type);
create
type
of shader(structure that manage shader code compile and linking it) and returnGLuint
as identifier.
- glShaderSource
void glShaderSource (GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length);
will add more explains
- glCompileShader
void glCompileShader (GLuint shader);
Compile
shader
indenfied shader.
- glCreateProgram
GLuint glCreateProgram (void);
create a program object and return its identifier.
- glAttachShader
void glAttachShader (GLuint program, GLuint shader);
attach
shader
toprogram
- glLinkProgram
void glLinkProgram (GLuint program);
as its name
- glDeleteShader
void glDeleteShader (GLuint shader);
as its name
- glDeleteProgram
void glDeleteProgram (GLuint program);
as its name
Vertex Shader manage #
Vertex Array #
- glGenVertexArrays
void glGenVertexArrays (GLsizei n, GLuint *arrays);
Generate
n
number of VAO(Vertex Array Object)s inarrays
.
since this function access GLuint as array, it requiresarrays
’ address as parameter.
- glBindVertexArray
void glBindVertexArray (GLuint array);
bind
array
(VAO) to current context.
ood #
- glDrawArrays
void glDrawArrays (GLenum mode, GLint first, GLsizei count);
send vertices to pipeline. started from
first
,count
of vertices with premitivemode
mode example: GL_POINTS, GL_LINES, GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_PATCHES, …
- glVertexAttrib
void glVertexAttrib4fv(GLuint index, const GLfloat *v);
set 4fv of vertex attribute to layout(loaction =
index
).
4fv means 4 float vector(array)
Tessellation Shader manage #
- glPatchParameteri
void glPatchParameteri (GLenum pname, GLint value);
tname example: GL_PATCH_VETICES
Geometry Shader manage #
Shader Built-in variable #
- gl_Position
(out) represents transform of vertex
- gl_VertexID
specify id used in vertex shader
(in) Ex: glDrawArrays) started fromfirst
,count
number of vertex
- gl_InvocationID
(in) used fo 0-based index of gl_in, gl_out
- gl_TessLevelInner
- gl_TessLevelOuter
(out) Tessellation factor variable array
contain tessellation level
- gl_TessCoord
(in)barycentric coodinate of vertex
EmitVertex()
make vertex with gl_Position of geometry shader
EndPrimitive()
automatically called when geometry shader end
- gl_FragCoord
(in)coordinate of fragment to manipulate
General #
- gl_in
- gl_out
not simple variable, but array
- floor
float floor (float f);
floor function in glsl.
i.e. return integer part of f
.trunc
funtion is used in absolute value’s case.
- fract
float fract (float f);
return fractional part of f
.
- mix
vec4 mix (vec4 A, vec4 B, float t);
linear interpolation.
has sevelar verstions take different dimensional vectors or scalars as A
and B
,t
shows iterpolating parameter represented by scalar or matching vector.
layout #
Vertex
layout (location = 0) in vec4 variablename;
//location used as attribute indexTesselation Control
layout (vertices = 3) out;
//output control point(vertices) per patchTesselation Evaluation
layout (triangles, equal_spacing, cw) in;
//setting for tessellation modeGeometry
layout (triangles) in;
layout (points, max_vertices = 3) out;
//get input as triangle and divide them into pointsFragment
Compute
layout (local_size_x = 32, local_size_y = 32) in;
//local workgroup szie is 32*32
extension #
#extension GL_extension_feature_en : enable //enable feature both device support it or not
#extension GL_extension_feature_re : required //if this extensio is not replaceable, use required for assertive code
#if GL_extension_feature_en
//extension's name will be defined with macro so you can manage code
#else
//alternative codes if extension doesn't supported
#endif
Fixed Block #
Pixel Operations #
scissor test => stencil test => depth test =>
Coordinate space #
Model space (=object space)
local origin following coordinate spaceWorld space
global origin following coordinate spaceView space (=camera, =eye space)
relative coordinate space to viewerClip space
coordniate space after projection on homogeneous coordinateNormalized device coordinate(NDC) space
coordinate space after dividing clip space by w componentWindow space
window origin following coordinate space
Transform #
- View - Clip Transform
can be performed by projection matrix : orthographic, perspective, etc…
occurs after Model - View Transform.
================================================================