OpenLLM-France/wikimedia huggingface dataset:
# Manchu/Vocab 3
## Countries (Gurun)
### Asia
#### East Asia

* Manju Gurun = Manchuria
* Dulimbai Gurun = China
** Dulimbai Irgen Gurun = Republic of China
*** Taiwan = Taiwan
* Monggo = Mongolia
* Solho = Korea
** Amargi Solho = North Korea
*** Also Jušen = Choson/Joseon
** Julergi Solho = South Korea
*** Also Han Gurun = Hanguk
* Šun da gurun or Nihon Gurun = Japan

#### Southeast Asia

* Filipin = Philippines
* Yendunisiya = Indonesia
* Lao Gurun = Laos
* Malaysiya = Malaysia
* Singapor = Singapore
* Tai Gurun = Thailand

#### South Asia

* Yendu Gurun = India
* Afuhan Gurun = Afghanistan
* Paji Gurun (?) = Pakistan
* Siri Lanka = Sri Lanka
* Butan = Bhutan
* Mael'daifu = Maldives
* Bengiala Gurun = Bangladesh

#### Middle East

* Turk Gurun = Turkey
* Isurael = Israel
* Saudi Arabiya = Saudi Arabia
* Yemen = Yemen
* Oman = Oman

#### Central Asia

* Kazak Gurun = Kazakhstan
* Turkuman Gurun = Turkmenistan
* Tajike Gurun = Tajikistan
* Kirgize Gurun = Kyrgyzstan
* Uzibeki Gurun = Uzbekistan

#### Southwest Asia
### Europe
#### Northern Europe

* Aislande = Iceland
* Norwai = Norway
* Suilande = Sweden
* Danmak = Denmark
* Finlande = Finlande

#### Eastern Europe

* Aistoniya = Estonia
* Bailarus = Belarus
* Latwiya = Latvia
* Lito'aniya = Lithuania
* Moldowa = Moldova
* Oros = Russia
* Ukraina = Ukraine

#### Central Europe

* Caik = Czech Republic
* Doicilande (Geli:Jermaini) = Germany
* Hanggaži = Hungary
* Liktensetain = Liechtenstein
* Ostoliya = Austria
* Polande = Polande
* Suidzerlande（Geli：Suis）= Switzerland
* Sulowakiya = Slovakia

#### Southern Europe

* Ailbeiniya = Albania
* Aindor = Andorra
* Bosniya jai Herts'egowiniya = Bosnia-Herzegovina
* Itali = Italy
* Gežis = Greece
* Jibžolter = Gibraltar
* Kežo'eiše = Cyprus
** Northern Cyprus = Amargi Kežo'eiše
* Maisdoniya = Macedonia
* Malta = Malta
* Montineigežo = Montenegro
* Porcugel = Portugal
* Romaniya = Romania
* Sain Mažino = San Marino
* Serbiya = Serbia
* Sulowiniya = Slovenia
* Supein = Spain
* Waitiken Hoton = Vatican City

#### Western Europe

* Ailande = Ireland
* Bailjem = Belgium
* Furangse = France
* Inggiri = England/United Kingdom/Britain
* Laksenbolge = Luxembourg
* Monako = Monaco
* Nedzelandzi = Netherlands

### North America

* Amerika or Mei Gurun = United States of America
* Kanada = Canada
* Mekesiko = Mexico
* Kuba = Cuba

### Africa

* Julergi Afrika = South Africa

### Oceania

* Avstraliya = Australia
* Ice Zelande = New Zealand

### South America

* Arjentina = Argentina
* Ekuwador = Ecuador
* Kolombiya = Colombia
* Farangse Gai'ana = French Guiana
* Gai'ana = Guyana
* Beliwiya = Bolivia
* Bežedzil = Brazil
* Pažaguwai = Paraguay
* Pežu = Peru
* Suinam = Surinam
* Cili = Chile
* Julergi Jorjiya jai Julergi Sandewice Geren Tun = South Georgia and South Sandwich Islands
* Yužuguwai = Uruguay
* Falkelande Geren Tun (Geli:Malwinas) = Falkland Islands/Malvinas
* Wenedziweila = Venezuela
# Japanese/Kanji/Lesson 2

| Meaning: six | 音読み： ロク | 六十 (ろくじゅう) sixty 六人 (ろくにん) six people 六月 (ろくがつ) June 十六 (じゅうろく) sixteen |
| Meaning: six | 訓読み： むっ（つ）, む（つ） | 六日 (むいか) sixth day, six days |
| 名乗り： く, むつ, ろっ, ろつ ||
| Meaning: seven | 音読み： シチ | 七人 (しちにん) seven people 七月 (しちがつ) July |
| Meaning: seven | 訓読み： なな(つ) | 七日 (なのか・なぬか) seventh day; seven days 十七 (じゅうなな) seventeen 七十 (ななじゅう) seventy |
| 名乗り： し, しっ, な, ひち ||
| Meaning: eight | 音読み： ハチ | 八人 (はちにん) eight people 八月 (はちがつ) August 十八 (じゅうはち) eighteen 八十 (はちじゅう) eighty |
| Meaning: eight | 訓読み： やっ(つ), よう, や | 八日 (ようか) eigth day; eight days 八重桜 (やえざくら) double cherry blossoms |
| 名乗り： な, は, はっ, はつ, やち, やつ ||
| Meaning: nine | 音読み： キュウ, ク | 九人 (きゅうにん, くにん) nine people 九月 (くがつ) September 十九 (じゅうきゅう, じゅうく) nineteen 九十 (きゅうじゅう) ninety |
| Meaning: nine | 訓読み： ここの(つ) | 九日 (ここのか) ninth day; nine days |
| 名乗り： いちじく, いちのく, この, ひさし ||
| Meaning: ten | 音読み： ジュウ, ジッ | 十人 (じゅうにん) ten people 十月 (じゅうがつ) October |
| Meaning: ten | 訓読み： とお, と | 十日 (とおか) tenth day; ten days |
| 名乗り： い, か, ぎ, さ, し, そ, そう, ち, とう, ね, ま, る, わ ||
# Japanese/Kanji/Lesson 12

| 半 Meaning: half | 音読み： ハン | 半分 (はんぶん) half; (はんぷん) half a minute 半日 (はんにち) half day 一時半 (いちじはん) half-past one (o'clock) |
| 半 Meaning: half | 訓読み： なか（ば） | |
| 分 Meaning: divide; small quantity (time) | 音読み： ブン,　フン,　ブ | 自分 (じぶん) one's self 分 (ふん) counter (minutes) 半分 (はんぶん) half |
| 分 Meaning: divide; small quantity (time) | 訓読み： わ(ける), わ(け), わ(かれる), わ(かる), わ(かつ) | 分かる (わかる) to be understood; to be comprehended; |
| Meaning: learn; knowledge | 音読み： ガク | 学校 (がっこう) school 学生 (がくせい) student 大学 (だいがく) college; university; |
| Meaning: learn; knowledge | 訓読み： まな(ぶ) | 学ぶ (まなぶ) to learn; to study (in depth); |
| Meaning: school | 音読み： コウ, キョウ | 高校 (こうこう) high school; 中学校 (ちゅうがっこう) middle school; |
| Meaning: school | 訓読み： | |
| Meaning: life; living; birth | 音読み： セイ,ショウ | 先生　(せんせい) teacher; doctor; master; 誕生日　（たんじょうび) birthday; |
| Meaning: life; living; birth | 訓読み： い(きる), い(かす), い(ける),う(まれる), う(まれ), うまれ, う(む), お(う), は(える), は(やす), き, なま〜,な(る), な(す) | 生きる　(いきる) to live 生かす (いかす) to make (the best) use of; to let live; 生まれる (うまれる) to be born; 生む (うむ) to give birth; |
# Japanese/Kanji/Lesson 13

| Meaning: mountain; hill | 音読み： サン、ザン、セン | 富士山（ふじさん） Mt. Fuji 登山（とざん） mountain climb |
| Meaning: mountain; hill | 訓読み： やま | 山梨県（やまなしけん） Yamanashi prefecture |
| Meaning: stream; river | 音読み： セン | 川柳（せんりゅう） haiku-like poem |
| Meaning: stream; river | 訓読み： かわ | 川下り（かわくだり） rafting |
| Meaning: white; pure | 音読み： ハク、ビャク | 白馬（はくば） white horse 白夜（びゃくや） Midnight sun |
| Meaning: white; pure | 訓読み： しろ、しら | 白い（しろい） white 白雪姫（しらゆきひめ） Snow White |
| Meaning: sky; heaven; god | 音読み： テン | 天気（てんき） weather |
| Meaning: sky; heaven; god | 訓読み： あま、あめ | 天の川（あまのがわ） Milky Way (Silvery River) |
| Meaning: rain | 音読み： ウ | 雨天（うてん） rainy weather |
| Meaning: rain | 訓読み： あめ、あま | 大雨（おおあめ） heavy rain 雨雲（あまぐも） nimbus |
# Japanese/Kanji/Lesson 14

| 電 Meaning: electricity; electric | 音読み： デン | 電気（でんき）electricity 電車（でんしゃ）train 電話（でんわ）phone 家電（かでん）consumer electronics 荷電（かでん）electric charge 外電（がいでん）foreign telegram 感電（かんでん）receive an electric shock 火力発電（かりょくはつでん）thermal power generation |
| 電 Meaning: electricity; electric | 訓読み： n/a | |
| Meaning: spirit; mind | 音読み： キ、ケ | 天気（てんき）Weather 平気（へいき）Normal, Feel normal 気分（きぶん）Feelings |
| Meaning: spirit; mind | 訓読み： いき | |
| Meaning: car, wheel | 音読み： シャ | 中古車（ちゅうこしゃ) Used car 駐車場（ちゅうしゃじょう) Parking space, Parking lot 新車（しんしゃ）New car |
| Meaning: car, wheel | 訓読み： くるま | 井戸車（いどぐるま）Well pulley |
| Meaning: country | 音読み： コク | ローマ帝国（ローマていこく）Roman Empire 韓国（かんこく）Korea 中国（ちゅうごく）China アメリカ合衆国（アメリカがっしゅうこく）the United States of America |
| Meaning: country | 訓読み： くに | わが国（わがくに）Our country (reserved for a Japanese referring to Japan); our land |
| Meaning: round; circle; yen | 音読み： エン | １００円（ひゃくえん）￥100 十円玉（じゅうえんだま）￥10 Coin |
| Meaning: round; circle; yen | 訓読み： まる | |
# Japanese/Kanji/Lesson 17

| Meaning: eye; class; look; insight; experience; care; favor | 音読み： モク、ボク | 項目 (こうもく) item; entry; |
| Meaning: eye; class; look; insight; experience; care; favor | 訓読み： め、～め、ま～、 | お披露目 (おひろめ) debut つなぎ目 (つなぎめ) a joint; a link; tie-together point 目 (め) counter for items in an ordered list; eye; |
| Meaning: ear | 音読み： ジ | 外耳 (がいじ) external ear; conch; |
| Meaning: ear | 訓読み： みみ | 兎耳 (うさぎみみ) long ears; gossiper; |
| Meaning: mouth; opening; | 音読み： コウ、ク | 火口 (かこう) crater, caldera |
| Meaning: mouth; opening; | 訓読み： くち | 出口 (でぐち) exit 入口 (いりぐち) entrance; opening; |
| Meaning: hand | 音読み： シュ、ズ | 上手 (じょうず) skillful; talented; |
| Meaning: hand | 訓読み： て、て～、～て、た～ | 右手 (みぎて) right hand 左手 (ひだりて) left hand 手紙 (てがみ) letter (mail) |
| Meaning: leg; foot; be sufficient; counter for pairs of footwear | 音読み： ソク | 足 (そく) counter for pairs (of socks, shoes, etc.) |
| Meaning: leg; foot; be sufficient; counter for pairs of footwear | 訓読み： あし、た（りる）、た（る）、た（す） | 足す (たす) to add (numbers, something, etc) 足りる (たりる) to be sufficient; |
# Japanese/Kanji/Lesson 15

| 話 Meaning: talk, speak | 音読み： ワ | 話題（わだい）：subject 童話（どうわ）：short stories for children |
| 話 Meaning: talk, speak | 訓読み： はな（す）, はなし | 昔話（むかしばなし）：folk tales |
| Meaning: hear; ask | 音読み： ブン | 新聞（しんぶん）：newspaper |
| Meaning: hear; ask | 訓読み： き（く） | |
| Meaning: eat | 音読み： ショク | 食事（しょくじ）：meal 和食（わしょく）：Japanese food 食パン(しょくパン)：sliced bread |
| Meaning: eat | 訓読み： たべ（る） | |
| Meaning: read | 音読み： ドク | 音読（おんどく）：reading aloud |
| Meaning: read | 訓読み： よ（む） | 読み物（よみもの）：reading materials |
| 来 Meaning: come | 音読み： ライ | 来月（らいげつ）：next month 来年（らいねん）：next year |
| 来 Meaning: come | 訓読み： く（る） | |
# Japanese/Kanji/Lesson 16

| 書 Meaning: write | 音読み： ショ | 文書（ぶんしょ） document 書道 （しょどう） calligraphy |
| 書 Meaning: write | 訓読み： か(く) | 書く（かく） to write |
| Meaning: encounter; see, look at | 音読み： ケン, ゲ | 見学（けんがく） tour |
| Meaning: encounter; see, look at | 訓読み： み(る) | 見る（みる） to look at |
| 行 Meaning: go; journey | 音読み： コウ、ギョウ、アン | 銀行（ぎんこう） bank 行列（ぎょうれつ） line of people / matrix (mathematics) |
| 行 Meaning: go; journey | 訓読み： い(く)、ゆ(く | 行き先（いきさき、ゆきさき） destination |
| Meaning: go out; leave | 音読み： シュツ、シュッ | 出発（しゅっぱつ） start, begin |
| Meaning: go out; leave | 訓読み： で(る) [to exit, leave], だ(す) [to put out, to emit, to send] | 出かける（でかける） to go out 追い出す（おいだす） to kick out |
| Meaning: enter; come | 音読み： ニュウ, ジュ, ジュウ | 入学（にゅうがく） enter a school |
| Meaning: enter; come | 訓読み： はい(る) [to enter], い(れる) [to insert], いり、いる、しお | 部屋に入る（へやにはいる） to enter a room 頭に入れる（あたまにいれる） to put something into one's mind / memorize |
# Japanese/Kanji/Lesson 18

| 新 Meaning: new | 音読み： シン | 新聞 （しんぶん） |
| 新 Meaning: new | 訓読み： あたら（しい）、あら（た）、あら～、にい～ | |
| 古 Meaning: old | 音読み： コ | |
| 古 Meaning: old | 訓読み： ふる（い） ふる- -ふる（す） | 古着（ふるぎ） 古時計 （ふるどけい） |
| Meaning: many; frequent; much | 音読み： タ | 多才（たさい） |
| Meaning: many; frequent; much | 訓読み： おお（い）、まさ（に）、まさ（る） | |
| 少 Meaning: few; little | 音読み： ショウ | 少女（しょうじょ） 少年（しょうねん） |
| 少 Meaning: few; little | 訓読み： すく（ない）、すこ（し） | |
| Meaning: empty; sky; void; vacant; vacuum | 音読み： クウ 空気（くうき） 空白（くうはく） | |
| Meaning: empty; sky; void; vacant; vacuum | 訓読み： そら、あ（く）、あ（き）、あ（ける）、から、す（く）、す（かす）、むな（しい） | 空手（からて） 冬空（ふゆぞら） 空き家（あきや） |
# Japanese/Kanji/Lesson 19

| 店 Meaning: store; shop | 音読み： テン |
| 店 Meaning: store; shop | 訓読み： みせ、たな |
| 社 Meaning: company; firm; office; association; shrine | 音読み： シャ |
| 社 Meaning: company; firm; office; association; shrine | 訓読み： やしろ |
| 買 Meaning: buy | 音読み： バイ |
| 買 Meaning: buy | 訓読み： か（う） |
| Meaning: stand up | 音読み： リツ、リュウ、リットル |
| Meaning: stand up | 訓読み： た（つ）、～た（つ）、た（ち）～、た（てる）、～た（てる）、た（て）～、たて～、～た（て）、～だ（て）、～だ（てる） |
| 安 Meaning: relax; cheap; low; quiet; rested; contented; peaceful | 音読み： アン |
| 安 Meaning: relax; cheap; low; quiet; rested; contented; peaceful | 訓読み： やす（い）、やす（まる）、やす、やす（らか） |
# Japanese/Kanji/Lesson 20

| Meaning: meeting; meet; party; association; interview; join | 音読み： カイ、エ |
| Meaning: meeting; meet; party; association; interview; join | 訓読み： あ（う）、あ（わせる）、あつ（まる） |
| 道 Meaning: road-way; street; district; journey; course; moral; teachings | 音読み： ドウ、トウ |
| 道 Meaning: road-way; street; district; journey; course; moral; teachings | 訓読み： みち |
| 飲 Meaning: drink; smoke; take | 音読み： イン、オン |
| 飲 Meaning: drink; smoke; take | 訓読み： の（む）、～の（み） |
| 駅 Meaning: station | 音読み： エキ |
| 駅 Meaning: station | 訓読み： None |
| Meaning: fish | 音読み： ギョ |
| Meaning: fish | 訓読み： うお、さかな、～ざかな |
# OpenGL Programming/Particle systems

This is a Work In Progress
A particle system is an optimized way to deal with a huge number of objects (several thousands to several millions).
The naive approach is to draw each object independently (as we did in most other tutorials), but drawing thousands of objects implies preparing and calling DrawArray/DrawElements thousands of times per frame, each implying an OpenGL round-trip, which is plain inefficient.
Instead, the goal is to draw loads of similar objects in one go.
We identify 2 mains way to render particle systems:
* Manipulating attributes on the CPU and rendering them on the GPU:
** On start-up, upload a single VBO of points (fast sprites with GL_POINTS), or a set of 3D objects all in a single VBO+EBO.
** At each frame, manipulate them on the CPU, uploading a VBO of attributes.
** At each frame, draw them with a single DrawArray/DrawElements call (same shader for all objects).
* Full-GPU particle system, computing with a tex1 = fragment_shader(tex2, tex3, ...) pattern:
** On start-up, store all particles initial attributes in textures (one texel = one particle's attribute).
** On start-up, upload a huge, static array of GL_POINTS (one per texel).
** At each frame, render a quad to a new result texture of the same size, combining the initial attributes in the fragment shader and storing the next particle state (e.g.: its next position). Several attributes can be computed with several shaders. Textures can be swapped to update old state to new state.
** At each frame, draw the static array of points: in the vertex shader, lookup the particle attributes (e.g. position) in the result texture(s).
** No per-frame upload!
* Special, intermediate case for non-incremental transformations (uniforms instead of attributes, e.g. linear motions): full-GPU if you compute the position procedurally in the vertex shader (no attributes manipulation)

# References

* three.js documentation - ParticleSystem: three.js implements a GL_POINTS-based particle system
* a thoroughly modern particle system: describe state of the art and design a GPU-side particle system
* WebGL particles: WebGL experiment implementing the GPU-side particle system described above, managing 260,000 particles
# Concept

Quadrics are a way to create simple shapes, such as spheres or cylinders, from their maths equations.
Quadrics are usually drawn using the GLU (OpenGL Utility) library. In this tutorial though, we target portability, in particular mobile devices, where GLU may just not be available, or only for OpenGL 1.x, so we'll implement it ourselves. In addition we've get a better understanding than merely call of few functions :)
We can draw quadrics differently:
* solid / wireframe
* front-facing on the outside / on the inside

# Solving the equation

So you might ask "How on earth am I going to solve a three variables equations?!". Well, the answer is to define x and y, using a grid, and compute z.
There are two main ways to draw a grid for x and y values:
* square grid: make N points along the x axis, and for each of them, make M points along the y axis. This is a classic double-for loop as used with 2-dimensional C arrays.
* disk grid: define a circle radius N times, and compute M points on the circle (using cos/sin).
Both methods will produce different results visually.
When solving the equation, we'll meet two forms:
* $z=EQUATION$ : z is computed directly
* $z^{2}=EQUATION$ : there are 3 cases:
** EQUATION is 0, and there's one solution (0)
** EQUATION is negative, and there's no solution
** otherwise, z has two solution, $\scriptstyle {\sqrt {EQUATION}}$ and $\scriptstyle -{\sqrt {EQUATION}}$

# Sphere

Equation : ${x^{2} \over a^{2}}+{y^{2} \over a^{2}}+{z^{2} \over a^{2}}=1$
So : $z^{2}=a^{2}-{x^{2}}-{y^{2}}$
So we have two z solutions for each (x,y) point (except when z = 0).

# Links

* Alternative way to draw a sphere by normalizing a cube
- Recent stats
< OpenGL Programming
# Introduction

Apart from color, depth and stencil buffers, most graphics cards also provide a so-called accumulation buffer. These are essentially color buffers with a precision 16 bits or more per color. However, it is not possible to draw directly into the accumulation buffer. Instead, there are only a few operations that work on the entire accumulation buffer at once.
* glAccum(GL_LOAD, value): Copy the contents of the normal color buffer, multiplied by value, to the accumulation buffer.
* glAccum(GL_RETURN, value): Copy the contents of the accumulation buffer, multiplied by value, to the color buffer.
* glAccum(GL_ACCUM, value): Add the contents of the normal color buffer, multiplied by value, to the accumulation buffer.
* glAccum(GL_ADD, value): Add value to all the pixels in the accumulation buffer.
* glAccum(GL_MULT, value): Multiply all the pixels in the accumulation buffer by value.
In all cases, value is a float. These functions make it easy to calculate the (weighted) sum or average of a number of frames. In this first tutorial, we will see how we can use this to easily add motion blur to almost any OpenGL program.

# Motion blur

Motion blur happens when objects move so fast (with respect to the camera), or the exposure time of a camera is so long, that during the exposure, some objects have moved more than half a pixel, and therefore appear smeared out. Motion blur is normally not desirable, but it is sometimes hard to avoid with real cameras, because the exposure time depends (for a large part) on the amount of light in the scene. The less light there is, the longer the exposure time, and the stronger the effect of motion blur is. This is one of the reasons that video shot outdoors with a camcorder "feels" different from video shot indoors with the same camera.

# Simulating motion blur

It is actually very easy to create motion blur effects with the accumulation buffer. The usual way an OpenGL application works is this:
Where the function do_time_evolution takes care of updating the coordinates of moving objects in the scene, and/or of the movement of the camera itself. After the scene is drawn, it is shown on screen with glSwapBuffers, and optionally you wait for a while to limit the framerate. To add motion blur, you can draw the scene multiple times with smaller timesteps, and only show the average of those:
The best effect is achieved by accumulating a large number of frames, but you will be quickly limited by the power of your GPU. It is best to make the number of frames you accumulate configurable, or otherwise try to automatically determine how many frames you can render within one full timestep.

# Exercises

* Add motion blur to any of the previous tutorials. The more interesting ones are the mini-portal and glescraft, where you can walk around the scene.
* If you are adding post-processing effects to your scene, should you do this before or after applying motion blur?
* In case your GPU doesn't provide an accumulation buffer, could you recreate glAccum functionality by rendering to textures?
# Optimization

In addition we can set up back-face culling:
* glEnable(GL_CULL_FACE); // disabled by default
* Behavior specified by glCullFace(GL_BACK) and glFrontFace(GL_CCW) by default
Covered in GLSL_Programming/GLUT/Cutaways.
Exemple: show a rotating cube with one of the facet missing - can we see inside the cube? What are the possible work-arounds?

# Sound input

* Use OpenAL to capture sound from microphone, upload data unmodified to graphics card, display oscilloscope signal.

# Image enhancement techniques

* Contrast and brightness adjustments.
* Gamma correction.
* Sharpening / blurring using small convolution matrices.
* Using multiple texture units to perform darkfield and flatfield correction of CCD/CMOS images.
* Combine multiple exposures into a single LDR image.
Technique: I will start with loading three textures, I, D and F, binding them to separate texture units, and calculating (I - D) * F in the fragment shader. For things like gamma correction and small convolutions I will use a single texture, so it can be applied either something that has been uploaded previously or the contents of a FBO.

# Depth sorting

Useful if your depth buffer has low precision, you want to do transparency, or for some shadow techniques

# Vertex water effect

One can achieve a "under water" effect by adding a random noise for each vertex:
srand is modified every 1/10 second, so the animation is not too frenzy.
I was trying a get a per-pixel postfx but this could be used for morphing effects and such.

# 2D Scaling as shaders?

Paul sends me:
    I just realised that there are a ton of upscaling algorithms for bitmap
    artwork and that it might be an interesting exercise to implement some
    or all of them using GPU shaders and modern OpenGL.
    http://research.microsoft.com/en-us/um/people/kopf/pixelart/supplementary/index.html
    http://scale2x.sourceforge.net/
Sounds like a good idea!
- Recent stats
< OpenGL Programming
multiple textures and
shader changed for different triangles
# When to optimize

A common pitfall is to be obsessed with optimization, to the point of spending a lot of coding time on tiny optimization, while complexifying the code and making it harder to debug.
Make sure you optimize when you have evidence that the impacted code truly slows down the application. Make measurements. Compare in different use cases and possibly different hardware.
Also, we recommend that when implementing a new feature, you write your first version as clear as possible, and optimize it in a second step when the feature works correctly.

# Measuring frame time

A common way to measure performance in applications is by the use of FPS, or Frames Per Second. However, because of the definition of FPS itself (frames / 1 second), it does not fully convey performance because of its non-linearity. There are many pages around the web that fully describe this, but the basic idea is this: A linear change in FPS does not result in a linear change in actual performance. A 450 FPS drop from 900 FPS is about 1 millisecond extra time, but a 5 FPS drop from 60 FPS is about.. 1 millisecond extra time. The amount of performance decrease is inversely related to the amount of FPS lost, so as FPS tends towards 0, execution time starts growing out of control fast. Yet, you only see a linear change in FPS, so you just shrug this off.
Instead, you should use frame time, or the amount of time needed to render 1 frame. Although it may seem counter-intuitive, it provides a reliable way to measure if code is causing a bottleneck.
Here's a simple code to display the amount of time taken per frame (measured in milliseconds) on the console:

# Vertical sync

Often, OpenGL is configured to wait for the physical screen's vertical refresh before pushing the new color buffer:
* this prevents tearing, a visual artifact that mixes part of the previous buffer with part of the new one
* there is no visual need to display more frames than what the screen can handle, typically 60-75Hz (depending on the screen)
* this saves resources such as the battery
However, this means that even if we can display 200 FPS, our application will be capped to 60-75 FPS, which makes it difficult to measure the performances.
In such case, it can be useful to disable the vertical sync:
* your graphic card driver may come with utilities to enable and disable it
* with Mesa, you can start your application with vblank_mode=0, or configure this behavior more permanently in ~/.drirc; some earlier versions have bugs, so you may have to try both.

# Stencil buffer tests

See performances tips in the Stencil buffer section.
- Recent stats
< OpenGL Programming