Skip to content

Commit e628a78

Browse files
PatriceJiangminggo
authored andcommitted
set attribute (#20417)
1 parent cfad5de commit e628a78

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

cocos/2d/CCCameraBackgroundBrush.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,8 @@ bool CameraBackgroundSkyBoxBrush::init()
425425
// disable blend
426426
pipelineDescriptor.blendDescriptor.blendEnabled = false;
427427

428-
layout->setAttribute(shaderinfos::attribute::ATTRIBUTE_NAME_POSITION, 0, backend::VertexFormat::FLOAT3, 0, false);
428+
auto attrNameLoc = _programState->getAttributeLocation(shaderinfos::attribute::ATTRIBUTE_NAME_POSITION);
429+
layout->setAttribute(shaderinfos::attribute::ATTRIBUTE_NAME_POSITION, attrNameLoc, backend::VertexFormat::FLOAT3, 0, false);
429430
layout->setLayout(sizeof(Vec3));
430431

431432
initBuffer();

tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ bool ShaderNode::initWithVertex(const std::string &vert, const std::string &frag
108108

109109
// init custom command
110110
auto layout = _programState->getVertexLayout();
111-
layout->setAttribute("a_position", 0, backend::VertexFormat::FLOAT2, 0, false);
111+
auto attrPosLoc = _programState->getAttributeLocation("a_position");
112+
layout->setAttribute("a_position", attrPosLoc, backend::VertexFormat::FLOAT2, 0, false);
112113

113114
float w = SIZE_X, h = SIZE_Y;
114115
Vec2 vertices[6] = { Vec2(0.0f,0.0f), Vec2(w,0.0f), Vec2(w,h), Vec2(0.0f,0.0f), Vec2(0.0f,h), Vec2(w,h) };

0 commit comments

Comments
 (0)