OpenGLSL 資料輸入

2021-07-24 11:16:59 字數 920 閱讀 4584

a、頂點 著色器中定義輸入:

b、**數值傳入呼叫介面:

void glvertexattribpointer( gluint index,

glint size,

glenum type,

glboolean normalized,

glsizei stride,

const glvoid * pointer);

其中我們**的是type:(參考表說明如下)

type

specifies the data type of each component in the array. symbolic constants:gl_byte, gl_short,gl_unsigned_short, gl_fixed, or gl_float are accepted. the initial value is gl_float.

前提:shader中定義的輸入為float型時

當如果**輸入型別設定為gl_float時,gpu會直接做資料拷貝進行處理。

當如果**輸入型別設定為非gl_float,也就是gl_byte, gl_short,gl_unsigned_short或者 gl_fixed時候,gpu會進行轉換處理,將相關型別資料轉為gl_float。

當然一切都會正常執行,但是問題是:

在iphone5這樣的gpu處理能力較差的裝置上就會出現費時的情況。因為gpu的資料型別轉換消耗了大部分時間。當然這個問題在iphone5s這樣的裝置上消耗就不會明顯。

openGLSL從0開始學習

首先,找了些優秀的學習 openglsl 雙緩衝 double buffer 機制 01 20getting 20started 03 20hello 20window opengl 三角形 01 20getting 20started 04 20hello 20 opengl shading la...

tensorflow資料輸入

tensorflow的資料輸入採用佇列 執行緒的機制,這樣可以使得系統更加輕量。如例項 獲取資料的列表 image list,label list read image label list images tf.convert to tensor self.image list,dtype tf.s...

input輸入資料

input主要是用來實現輸入的函式,在python3中,input預設接收到得是str型別,所以不管輸入什麼都以字串型別出現 python用input 函式進行輸入,但是input 函式把輸入的值返回為字串型別,可是有些時候我們需要int型別,於是出現了int 函式,它可以把字串型別強制轉換為int...