Color of OpenGL ES coloring machine language

Source: Internet
Author: User
Tags bitwise

OpenGL ES coloring language is two closely related languages. These languages are used to create a shader on the programmable processor of the OpenGL ES processing pipeline. Unless otherwise stated in this document, a language function applies to all languages and is generally used as a language. Specific languages will point out their target processors: vertext or fragment ).

Any OpenGL ES status value used by the shader will be automatically tracked and applied to the shader. This automatic state tracking mechanism allows applications to use OpenGL ES state commands for State management, and these State values are automatically applied to the shader.

2.1 vertex Processor

A vertex processor is a programmable unit that processes input vertices and related data. The compiling unit for running this processor in OpenGL ES coloring language is called vertex shader ).

A vertex shader can process only one vertex at a time.

2.2 yuan Processor

The chip processor is a programmable unit for processing the chip and related data. The compilation unit for running this processor in OpenGL ES coloring language is called fragment shader ).

The position of the element cannot be changed. Access to adjacent slices is not allowed. The calculated value of the bitwise coloring er is used to update the frame buffer memory or texture memory. This depends on the current OpenGL ES status and the command to generate the bitwise.

3.1 Character Set

The source Character Set of OpenGL ES coloring language is a subset of ASCII encoding, which contains the following characters:

Character A-Z, A-Z, and underline (_).

Number 0-9.

Point (.), plus sign (+), split line (-), diagonal line (/), asterisks (*), percent sign (%), greater than or less than sign (<and> ), square brackets ([and]), Parentheses (and), braces ({And}), inserted symbols (^), vertical bars (|), and (&), tilde (~), Equal to (=), exclamation point (!), Colon (:), semicolon (;), comma (,), hello (?).

# Is used as a pre-processor.

Space: space character, horizontal tab, vertical tab, page feed, carriage return, line feed.

The line connector (\) is not part of the language.

In short, the character set used by the language is case sensitive.

No character or string type. Therefore, the character set does not contain quotation marks.

There is no file Terminator. The compiler uses the string length to determine the end of a string, rather than a specific character.

3.2 source string

The source of a shader is an array of Characters in the character set. The shader is connected by these strings. Each string can span multiple rows. A single row can contain multiple strings.

In this version of the coloring language, only one vertex coloring er and one metacoloring er can be linked together.

3.3 logic phase of compilation

Compilation is a subset of Standard C ++. The compilation unit of the vertex and the chip metadatabase processor is processed separately before the final stage of compilation-the link. The logic phase of compilation is as follows:

1. Source string Link

2. The source string is converted into a pre-processing symbol sequence. These symbols include pre-processed numbers, identifiers, and operators. The comment is replaced with a space while the linefeed is retained.

3. pre-processor execution.

4. The glsl es syntax parses the converted symbols.

5. link the uniform, verying, and fixed function variables.

3.4 pre-processor

# Define

# UNDEF

# If

# Ifdef

# Ifndef

# Else

# Elif

# Endif

# Error

# Pragma

# Extension

# Version

# Line

Defined

_ Line _ row number

_ File name

_ Version number

The gl_es value is 1, indicating that the es OpenGL rendering language is used.

Operator priority and associativity:

DefinedOperator usage:

Defined identifier

Defined (identifier)

# Error // Save the diagnostic information to the information log of the Shadow object

# Pragma // allow sub-compilation control. # The symbols after Pragma are not part of the pre-processing macro definition extension. If the symbol after # pragma cannot be identified, this # pragma will be ignored. Yes

The Pragma used is as follows:

# Pragma stdgl // stdgl Pragma is a reserved Pragma for future language revisions. If this macro is not implemented, the macro definition starting with it will be used.

# Pragma optimize (on)
# Pragma optimize (off) // used to enable and disable the optimization operations for the development and debugging of the colorant. By default, all the optimization operations for the colorant are enabled, it can only be used outside the function definition.

# Pragma debug (on)

# Pragma debug (off) // compile and annotate a shader and output debugging information. Therefore, it can be used as a debugger. It can only be used outside the function. It is disabled by default.

# VersionNumber// Returns the version number of the current coloring language.

By default, the color language compiler must publish syntactic, syntactic, and semantic errors during compilation. Any extended behavior must be activated first. The instruction for controlling compiler extension behavior is # extension:

# Extension extension_name: Behavior

# Extension all: Behavior

Extension_name is the extension name, which is not input in this instruction document. The symbol all means that the behavior acts on all extensions supported by the compiler. The behavior values are as follows: require, enable, warn, and disable.

3.5 annotations

/* Comment out a module */

// Comment a row

3.6 symbols

A coloring language is a symbolic sequence that can contain the following symbols:

Keyword, identifier, integer constant, floating-point constant, operand

3.7 keywords

The following are the keywords used by the coloring language:

Attribute const uniform varying
Break continue do for while
If else
In out inout
Float int void bool True False
Lowp mediump highp precision Invariant
Discard return
Mat2 mat3 mat4
Vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4
Sampler2d samplercube
Struct

The following are reserved keywords:

ASM
Class Union Enum typedef template this packed
Goto switch default
Inline noinline volatile public static extern external interface flat
Long short double half fixed unsigned superp
Input Output
Hvec2 hvec3 hvec4 dvec2 dvec3 dvec4 fvec2 fvec3 fvec4
Sampler1d sampler3d
Sampler1dshadow sampler2dshadow
Sampler2drect sampler3drect sampler2drectshadow
Sizeof cast
Namespace using

3.8 identifier

The identifier is used as the variable name, function name, struct name, and domain selector name (select the element of the vector and matrix, similar to the struct field ). Identifier naming rules:

(1) It cannot start with a number, but can only start with a letter or underline

(2) It cannot start with "Gl _". This is reserved by OpenGL.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.