openGL

[TOC]

opengl.org: official website of OpenGL.
OpenGL registry: hosts the OpenGL specifications and extensions for all OpenGL versions.
  • GLFW: Window Guide: official GLFW guide on setting up and configuring a GLFW window.
  • Building applications: provides great info about the compilation/linking process of your application and a large list of possible errors (plus solutions) that might come up.
  • GLFW with Code::Blocks: building GLFW in Code::Blocks IDE.
  • Running CMake: short overview of how to run CMake on both Windows and Linux.
  • Writing a build system under Linux: an autotools tutorial by Wouter Verholst on how to write a build system in Linux, specifically targeted for these tutorials.
  • Polytonic/Glitter: a simple boilerplate project that comes pre-configured with all relevant libraries; great for if you want a sample project for the LearnOpenGL tutorials without the hassle of having to compile all the libraries yourself.

openGL ES

OpenGL for Embedded Systems (OpenGL ES) is a simplified version of OpenGL that eliminates redundant functionality to provide a library that is both easier to learn and easier to implement in mobile graphics hardware.

../Art/cpu_gpu_2x.png

https://www.khronos.org/

https://www.khronos.org/ —> search -> keyword: ES shading language

what’s OpenGL

https://learnopengl.com/Getting-started/Hello-Triangle

OpenGL is a 3D graphics library so all coordinates that we specify in OpenGL are in 3D (x, y and z coordinate) OpenGL doesn’t simply transform all your 3D coordinates to 2D pixels on your screen; OpenGL only processes 3D coordinates when they’re in a specific range between -1.0 and 1.0 on all 3 axes (x, y and z). All coordinates within this so called normalized device coordinates range will end up visible on your screen (and all coordinates outside this region won’t).

NDC 归一化设备坐标系

Normalized Device Coordinates (NDC)

Once your vertex coordinates have been processed in the vertex shader, they should be in normalized device coordinates which is a small space where the x, y and z values vary from -1.0 to 1.0. Any coordinates that fall outside this range will be discarded/clipped and won’t be visible on your screen. Below you can see the triangle we specified within normalized device coordinates (ignoring the z axis):

image-20200317105608064

Unlike usual screen coordinates the positive y-axis points in the up-direction and the (0,0) coordinates are at the center of the graph, instead of top-left. 与屏幕坐标系 原点不同,y轴 也不同吗?

Eventually you want all the (transformed) coordinates to end up in this coordinate space, otherwise they won’t be visible.

Your NDC coordinates will then be transformed to screen-space coordinates via the viewport transform using the data you provided with glViewport. The resulting screen-space coordinates are then transformed to fragments as inputs to your fragment shader.

primitive 图元 hints

Those hints are called primitives and are given to OpenGL while calling any of the drawing commands. Some of these hints are GL_POINTS, GL_TRIANGLES and GL_LINE_STRIP.

vertex shader

The main purpose of the vertex shader is to transform 3D coordinates into different 3D coordinates (more on that later) and the vertex shader allows us to do some basic processing on the vertex attributes.

primitive assembly

geometry shader

rasterization stage

fragment shader

The main purpose of the fragment shader is to calculate the final color of a pixel and this is usually the stage where all the advanced OpenGL effects occur. Usually the fragment shader contains data about the 3D scene that it can use to calculate the final pixel color (like lights, shadows, color of the light and so on)

A fragment in OpenGL is all the data required for OpenGL to render a single pixel.

GPU:VBO vertex buffer objects

We manage this memory via so called vertex buffer objects (VBO) that can store a large number of vertices in the GPU’s memory.

vulkan

https://www.khronos.org/vulkan/

Important OpenGL ES was deprecated in iOS 12. To create high-performance code on GPUs, use the Metal framework instead. See Metal. detail

OpenGL 中,任何事物都在 3D 空间中

ES shading language https://www.khronos.org/search/?cx=017055583490642512057%3A_ak1bpok_no&cof=FORID%3A9&q=ES+shading+Language

OpenGL specification of version 3.3 here

OpenGL Shading Language - OpenGL Wiki - Khronos Group

The OpenGL ES Shading Language - Khronos Group

The OpenGL ES Shading Language - Khronos Group

The OpenGL ES® Shading Language, Version 3.20.6 Jul 10, 2019

The OpenGL ES Shading Language - Khronos Group


The OpenGL® Shading Language, Version 4.60.7 - Khronos Group

The OpenGL ES Shading Language - Khronos Group


book

OpenGL ES 2.0 API 快速参考卡片 pdf

红宝书:OpenGL Programming Guide

蓝宝书:OpenGL Superbible


adopting openGL ES 3.0

great resources on Metal and OpenGL.

the OpenGL tutorial.

moving from openGL to Metal

GLKit Tutorial for iOS: Getting started with OpenGL ES

OpenGL ES Programming Guide for iOS

Learn OpenGL

OpenGL ES 01 OpenGL ES之初体验

Opengles Shading Language

游戏人 OpenGL ES 2.0 着色器语言GLSL

source

GLImageProcessing iOS code samples demonstrating how to use OpenGL ES 2.0 for common image processing task

GPUImage

BCMeshTransformView

Idea

Shadertoy 示例

PhotoFunia

state-setting function

state-using function

As you might recall from the OpenGL tutorial, the glClearColor function is a state-setting function and glClear is a state-using function in that it uses the current state to retrieve the clearing color from.

着色器

片段着色器

片段着色器是 在图元进行 光栅化后对片段(最基本是像素)进行填充。不过, 顶点数据都可以通过顶点程序传递到片段着色器。

OpenGL ES 2.0 for iOS, Chapter 4 - Introducing the Programmable Pipeline

The w in vec4(x, y, z, w) is used for clipping, and plays its part while linear algebra transformations are applied to the position.

By default, this should be set to 1.0.

See here for some more info:

http://web.archive.org/web/20160408103910/http://iphonedevelopment.blogspot.com/2010/11/opengl-es-20-for-iOS-chapter-4.html

https://colin1994.github.io/2017/04/01/OpenGLES-Menu/

openGL shader 的基本概念

OpenGL SuperBible Source Code

http://www.openglsuperbible.com/previous-editions/

https://github.com/openglsuperbible

ios13.2/Frameworks/OpenGLES/gltypes.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
Copyright: (c) 2010-2012 Apple Inc. All rights reserved.
*/
#ifndef __gltypes_h_
#define __gltypes_h_

#include <stdint.h>

typedef uint32_t GLbitfield;
typedef uint8_t GLboolean;
typedef int8_t GLbyte;
typedef float GLclampf;
typedef uint32_t GLenum;
typedef float GLfloat;
typedef int32_t GLint;
typedef int16_t GLshort;
typedef int32_t GLsizei;
typedef uint8_t GLubyte;
typedef uint32_t GLuint;
typedef uint16_t GLushort;
typedef void GLvoid;

#if !defined(GL_ES_VERSION_2_0)
typedef char GLchar;
#endif
typedef int32_t GLclampx;
typedef int32_t GLfixed;
#if !defined(GL_ES_VERSION_3_0)
typedef uint16_t GLhalf;
#endif
#if !defined(GL_APPLE_sync) && !defined(GL_ES_VERSION_3_0)
typedef int64_t GLint64;
typedef struct __GLsync *GLsync;
typedef uint64_t GLuint64;
#endif
typedef intptr_t GLintptr;
typedef intptr_t GLsizeiptr;

#endif

ios Metal

Documentation

Browse the latest documentation including API reference and articles.