Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: INT attribute format for WebGL2 #10347

Merged
merged 4 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/rendering/renderers/gl/context/GlContextSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@ export class GlContextSystem implements System<ContextSystemOptions>
...common,
colorBufferFloat: gl.getExtension('EXT_color_buffer_float'),
};

const provokeExt = gl.getExtension('WEBGL_provoking_vertex');

if (provokeExt)
{
provokeExt.provokingVertexWEBGL(provokeExt.FIRST_VERTEX_CONVENTION_WEBGL);
}
}
}

Expand Down
28 changes: 21 additions & 7 deletions src/rendering/renderers/gl/geometry/GlGeometrySystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,9 @@ export class GlGeometrySystem implements System
const attribute = attributes[j];
const buffer = attribute.buffer;
const glBuffer = bufferSystem.getGlBuffer(buffer);
const programAttrib = program._attributeData[j];

if (program._attributeData[j])
if (programAttrib)
{
if (lastBuffer !== glBuffer)
{
Expand All @@ -380,12 +381,25 @@ export class GlGeometrySystem implements System

const attributeInfo = getAttributeInfoFromFormat(attribute.format);

gl.vertexAttribPointer(location,
attributeInfo.size,
getGlTypeFromFormat(attribute.format),
attributeInfo.normalised,
attribute.stride,
attribute.offset);
const type = getGlTypeFromFormat(attribute.format);

if (programAttrib.format?.substring(1, 4) === 'int')
{
gl.vertexAttribIPointer(location,
attributeInfo.size,
type,
attribute.stride,
attribute.offset);
}
else
{
gl.vertexAttribPointer(location,
attributeInfo.size,
type,
attributeInfo.normalised,
attribute.stride,
attribute.offset);
}

if (attribute.instance)
{
Expand Down