簡體   English   中英

VertexShader在Windows上編譯失敗,相同的代碼在Linux上工作

[英]VertexShader compile fails on windows, same code works on linux

我在這里關注OpenGL教程。 它可以在我的Arch Linux系統上完美運行,但不能在Windows上運行。

我的頂點和片段着色器代碼與示例完全相同:

片段着色器代碼:

#version 330 core

in vec2 UV;
out vec3 color;
uniform sampler2D myTextureSampler;

void main(){
  color = texture2D( myTextureSampler, UV ).rgb;
}

頂點着色器代碼:

#version 330 core

layout(location = 0) in vec3 vertexPosition_modelspace;
layout(location = 1) in vec2 vertexUV;
out vec2 UV;
uniform mat4 MVP;

void main(){
  gl_Position =  MVP * vec4(vertexPosition_modelspace,1);
  UV = vertexUV;
}

我在Windows上收到以下錯誤:

ERROR: 0:16: 'texture2D' : no matching overloaded function found (using implicit conversion)
ERROR: 0:16: 'rgb' :  field selection requires structure, vector, or matrix on left hand side
ERROR: 0:16: 'assign' :  cannot convert from 'const float' to 'FragUserData 3-component vector of float'

您有什么想法可能是問題嗎?

這在v330規范中以@mrVoid的形式列出。 現在已棄用所有舊的紋理采樣功能(1D / 2D / 3D),而應使用重載的功能:

texture(...)函數

該函數將根據您提供的采樣器類型而變化,因此不再需要在函數名稱中顯式定義正在使用的類型。 我在前往GL330的旅途中犯了這個錯誤。

暫無
暫無

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

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