簡體   English   中英

使用Qt5 OpenGL 3.3替換glSecondaryColorPointerEXT

[英]glSecondaryColorPointerEXT replacement using Qt5 OpenGL 3.3

我正在學習用Qt5重寫一些舊代碼的OpenGL。 他們使用glSecondaryColorPointerEXT()。 在檢查了通用視頻卡中對OpenGL的當前支持之后,我選擇了Qt5的類QOpenGLFunctions_3_2_Core來訪問OpenGL函數。

此功能是否有OpenGL 3.2版本或替換方法?

在OpenGL 3.2中,您應該使用着色器,此外,到此時,您應該避免使用gl_SecondaryColor類的舊功能。 在基於着色器的引擎中,適當替換第二顏色只是一個附加的通用頂點屬性。 我解釋了一個與OpenGL ES 2.0相關的非常相似的問題 ,我的回答可能會有幫助。

簡而言之,OpenGL 3.0中已棄用glVertexPointer (...)glColorPointer (...)glSecondaryColorPointer{EXT} (...) 在3.2核心環境中,您根本無法使用它們。 因此,您需要學習着色器和glVertexAttribPointer (...)

在核心GL 3.2中使用“主要”和“次要”頂點顏色的頂點着色器看起來像這樣:

#version 150 core

uniform mat4 mvp;

in      vec4 vtx_pos;
in      vec4 vtx_color1;
in      vec4 vtx_color2;

out     vec4 color;

void main (void) {
  gl_Position = mvp * vtx_pos;
  color       = vtx_color1 * vtx_color2; // It is up to you to decide what to do
                                         //   with the primary and secondary
                                         //     colors, this is just for show...
}

您可以使用glVertexAttribPointer (...)使用從GLSL頂點着色器查詢的屬性位置(鏈接后),將數據提供給vtx_pos,vtx_color1和vtx_color2。 所有這些完全消除了對glSecondaryColorPointerEXT (...)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM