久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='iayyQ'></bdo><ul id='iayyQ'></ul>
    <i id='iayyQ'><tr id='iayyQ'><dt id='iayyQ'><q id='iayyQ'><span id='iayyQ'><b id='iayyQ'><form id='iayyQ'><ins id='iayyQ'></ins><ul id='iayyQ'></ul><sub id='iayyQ'></sub></form><legend id='iayyQ'></legend><bdo id='iayyQ'><pre id='iayyQ'><center id='iayyQ'></center></pre></bdo></b><th id='iayyQ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='iayyQ'><tfoot id='iayyQ'></tfoot><dl id='iayyQ'><fieldset id='iayyQ'></fieldset></dl></div>

    1. <tfoot id='iayyQ'></tfoot>

      1. <legend id='iayyQ'><style id='iayyQ'><dir id='iayyQ'><q id='iayyQ'></q></dir></style></legend>

        <small id='iayyQ'></small><noframes id='iayyQ'>

        C++ 和 OpenGL 矩陣順序之間的混淆(行優先 vs 列優先

        Confusion between C++ and OpenGL matrix order (row-major vs column-major)(C++ 和 OpenGL 矩陣順序之間的混淆(行優先 vs 列優先))
        1. <small id='TYjHK'></small><noframes id='TYjHK'>

          <legend id='TYjHK'><style id='TYjHK'><dir id='TYjHK'><q id='TYjHK'></q></dir></style></legend>

            <tbody id='TYjHK'></tbody>
            • <bdo id='TYjHK'></bdo><ul id='TYjHK'></ul>

                <tfoot id='TYjHK'></tfoot>

                  <i id='TYjHK'><tr id='TYjHK'><dt id='TYjHK'><q id='TYjHK'><span id='TYjHK'><b id='TYjHK'><form id='TYjHK'><ins id='TYjHK'></ins><ul id='TYjHK'></ul><sub id='TYjHK'></sub></form><legend id='TYjHK'></legend><bdo id='TYjHK'><pre id='TYjHK'><center id='TYjHK'></center></pre></bdo></b><th id='TYjHK'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='TYjHK'><tfoot id='TYjHK'></tfoot><dl id='TYjHK'><fieldset id='TYjHK'></fieldset></dl></div>
                  本文介紹了C++ 和 OpenGL 矩陣順序之間的混淆(行優先 vs 列優先)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我對矩陣定義感到非常困惑.我有一個矩陣類,它包含一個 float[16],我認為它是行優先的,基于以下觀察:

                  float matrixA[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };浮點矩陣B[4][4] = { { 0, 1, 2, 3 }, { 4, 5, 6, 7 }, { 8, 9, 10, 11 }, { 12, 13, 14, 15 } };

                  matrixAmatrixB 在內存中都具有相同的線性布局(即所有數字都按順序排列).根據 http://en.wikipedia.org/wiki/Row-major_order 這表示行主要布局.

                  matrixA[0] == matrixB[0][0];矩陣A[3] == 矩陣B[0][3];矩陣A[4] == 矩陣B[1][0];矩陣A[7] == 矩陣B[1][3];

                  因此,matrixB[0] = 第 0 行,matrixB[1] = 第 1 行,等等.同樣,這表示行優先布局.

                  當我創建一個如下所示的翻譯矩陣時,我的問題/困惑就出現了:

                  1, 0, 0, transX0, 1, 0, transY0, 0, 1, 反Z0, 0, 0, 1

                  在內存中的布局為,{ 1, 0, 0, transX, 0, 1, 0, transY, 0, 0, 1, transZ, 0, 0, 0, 1 }.

                  然后當我調用 glUniformMatrix4fv 時,我需要將轉置標志設置為 GL_FALSE, 表明它是列優先的,否則轉換/縮放等轉換無法正確應用:

                  <塊引用>

                  如果轉置為 GL_FALSE,則假定每個矩陣都在列主要訂單.如果轉置為 GL_TRUE,則假設每個矩陣為以行主要順序提供.

                  為什么我的矩陣看起來是行優先的,但需要作為列優先傳遞給 OpenGL?

                  解決方案

                  opengl 文檔中使用的矩陣表示法沒有描述 OpenGL 矩陣的內存布局

                  如果您認為放棄/忘記整個行/列主要"的事情會更容易.那是因為除了行/列專業之外,程序員還可以決定他希望如何在內存中布置矩陣(相鄰元素形成行還是列),除了符號之外,這增加了混亂.

                  OpenGL 矩陣具有與 directx 矩陣相同的內存布局.

                  x.x x.y x.z 0y.x y.y y.z 0z.x z.y z.z 0p.x p.y p.z 1

                  { x.x x.y x.z 0 y.x y.y y.z 0 z.x z.y z.z 0 p.x p.y p.z 1 }

                  • x、y、z 是描述矩陣坐標系(相對于全局坐標系內的局部坐標系)的 3 分量向量.

                  • p 是描述矩陣坐標系原點的 3 分量向量.

                  這意味著翻譯矩陣應該像這樣在內存中布局:

                  { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, transX, transY, transZ, 1 }.

                  就這樣吧,剩下的就很簡單了.

                  ---引自舊的opengl faq--

                  <小時><塊引用>

                  9.005 OpenGL 矩陣是列優先還是行優先?

                  出于編程目的,OpenGL 矩陣是 16 值數組,基向量在內存中連續排列.平移分量占據了 16 元素矩陣的第 13、14 和 15 個元素,其中索引從 1 到 16 編號,如 OpenGL 2.1 規范的第 2.11.2 節所述.

                  列優先與行優先純粹是一種符號約定.請注意,使用列主矩陣進行后乘會產生與使用行主矩陣進行預乘相同的結果.OpenGL 規范和 OpenGL 參考手冊都使用列優先表示法.您可以使用任何符號,只要清楚說明即可.

                  遺憾的是,規范和藍皮書中使用列優先格式導致 OpenGL 編程社區無休止的混亂.列優先表示法表明矩陣并不像程序員所期望的那樣在內存中布置.

                  <小時>

                  I'm getting thoroughly confused over matrix definitions. I have a matrix class, which holds a float[16] which I assumed is row-major, based on the following observations:

                  float matrixA[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
                  float matrixB[4][4] = { { 0, 1, 2, 3 }, { 4, 5, 6, 7 }, { 8, 9, 10, 11 }, { 12, 13, 14, 15 } };
                  

                  matrixA and matrixB both have the same linear layout in memory (i.e. all numbers are in order). According to http://en.wikipedia.org/wiki/Row-major_order this indicates a row-major layout.

                  matrixA[0] == matrixB[0][0];
                  matrixA[3] == matrixB[0][3];
                  matrixA[4] == matrixB[1][0];
                  matrixA[7] == matrixB[1][3];
                  

                  Therefore, matrixB[0] = row 0, matrixB[1] = row 1, etc. Again, this indicates row-major layout.

                  My problem / confusion comes when I create a translation matrix which looks like:

                  1, 0, 0, transX
                  0, 1, 0, transY
                  0, 0, 1, transZ
                  0, 0, 0, 1
                  

                  Which is laid out in memory as, { 1, 0, 0, transX, 0, 1, 0, transY, 0, 0, 1, transZ, 0, 0, 0, 1 }.

                  Then when I call glUniformMatrix4fv, I need to set the transpose flag to GL_FALSE, indicating that it's column-major, else transforms such as translate / scale etc don't get applied correctly:

                  If transpose is GL_FALSE, each matrix is assumed to be supplied in column major order. If transpose is GL_TRUE, each matrix is assumed to be supplied in row major order.

                  Why does my matrix, which appears to be row-major, need to be passed to OpenGL as column-major?

                  解決方案

                  matrix notation used in opengl documentation does not describe in-memory layout for OpenGL matrices

                  If think it'll be easier if you drop/forget about the entire "row/column-major" thing. That's because in addition to row/column major, the programmer can also decide how he would want to lay out the matrix in the memory (whether adjacent elements form rows or columns), in addition to the notation, which adds to confusion.

                  OpenGL matrices have same memory layout as directx matrices.

                  x.x x.y x.z 0
                  y.x y.y y.z 0
                  z.x z.y z.z 0
                  p.x p.y p.z 1
                  

                  or

                  { x.x x.y x.z 0 y.x y.y y.z 0 z.x z.y z.z 0 p.x p.y p.z 1 }
                  

                  • x, y, z are 3-component vectors describing the matrix coordinate system (local coordinate system within relative to the global coordinate system).

                  • p is a 3-component vector describing the origin of matrix coordinate system.

                  Which means that the translation matrix should be laid out in memory like this:

                  { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, transX, transY, transZ, 1 }.
                  

                  Leave it at that, and the rest should be easy.

                  ---citation from old opengl faq--


                  9.005 Are OpenGL matrices column-major or row-major?

                  For programming purposes, OpenGL matrices are 16-value arrays with base vectors laid out contiguously in memory. The translation components occupy the 13th, 14th, and 15th elements of the 16-element matrix, where indices are numbered from 1 to 16 as described in section 2.11.2 of the OpenGL 2.1 Specification.

                  Column-major versus row-major is purely a notational convention. Note that post-multiplying with column-major matrices produces the same result as pre-multiplying with row-major matrices. The OpenGL Specification and the OpenGL Reference Manual both use column-major notation. You can use any notation, as long as it's clearly stated.

                  Sadly, the use of column-major format in the spec and blue book has resulted in endless confusion in the OpenGL programming community. Column-major notation suggests that matrices are not laid out in memory as a programmer would expect.


                  這篇關于C++ 和 OpenGL 矩陣順序之間的混淆(行優先 vs 列優先)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  In what ways do C++ exceptions slow down code when there are no exceptions thown?(當沒有異常時,C++ 異常會以何種方式減慢代碼速度?)
                  Why catch an exception as reference-to-const?(為什么要捕獲異常作為對 const 的引用?)
                  When and how should I use exception handling?(我應該何時以及如何使用異常處理?)
                  Scope of exception object in C++(C++中異常對象的范圍)
                  Catching exceptions from a constructor#39;s initializer list(從構造函數的初始化列表中捕獲異常)
                  Difference between C++03 throw() specifier C++11 noexcept(C++03 throw() 說明符 C++11 noexcept 之間的區別)

                      <tfoot id='hA2Hp'></tfoot>
                        <tbody id='hA2Hp'></tbody>

                      <small id='hA2Hp'></small><noframes id='hA2Hp'>

                        <legend id='hA2Hp'><style id='hA2Hp'><dir id='hA2Hp'><q id='hA2Hp'></q></dir></style></legend>
                        <i id='hA2Hp'><tr id='hA2Hp'><dt id='hA2Hp'><q id='hA2Hp'><span id='hA2Hp'><b id='hA2Hp'><form id='hA2Hp'><ins id='hA2Hp'></ins><ul id='hA2Hp'></ul><sub id='hA2Hp'></sub></form><legend id='hA2Hp'></legend><bdo id='hA2Hp'><pre id='hA2Hp'><center id='hA2Hp'></center></pre></bdo></b><th id='hA2Hp'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='hA2Hp'><tfoot id='hA2Hp'></tfoot><dl id='hA2Hp'><fieldset id='hA2Hp'></fieldset></dl></div>

                            <bdo id='hA2Hp'></bdo><ul id='hA2Hp'></ul>

                            主站蜘蛛池模板: 久久久精品网站 | 精品国产乱码久久久久久影片 | 在线观看日韩精品视频 | 欧美一区视频 | 国产视频一区二区在线观看 | 亚州春色 | 欧美a级成人淫片免费看 | 国产一级免费视频 | 精品视频在线免费观看 | 日韩成人一区 | 欧美激情五月 | 91国在线 | 女人毛片a毛片久久人人 | 亚洲天堂一区二区 | 日韩国产在线 | 操操网站| 99精品视频一区二区三区 | 午夜免费电影院 | 色综合桃花网 | 日本a∨精品中文字幕在线 亚洲91视频 | 成人av网站在线观看 | 日韩在线第一 | 日韩电影一区二区三区 | 亚洲欧洲日本国产 | 99热在线播放 | 精品不卡 | 国内自拍偷拍 | 久久久久午夜 | 黄色一级大片在线免费看产 | 日韩中文字幕免费 | 操久久 | 我要看黄色录像一级片 | 精品国产鲁一鲁一区二区张丽 | 亚洲精品一区二区三区免 | 国产一级淫片a直接免费看 免费a网站 | 五月激情婷婷网 | 午夜久草 | 日本一区二区三区四区 | 欧美日韩一区在线 | 爱草视频 | 久久久久香蕉视频 |