Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 29, 2025

Adds missing WebGL 1.0 vertexAttrib[1234]fv methods that accept Float32Array or array arguments for setting vertex attribute values.

Changes

Command Buffer Layer

  • Added COMMAND_BUFFER_VERTEX_ATTRIB_[1-4]FV_REQ types
  • Implemented VertexAttrib[1-4]fvCommandBufferRequest classes using template pattern

Graphics API

  • Added vertexAttrib[1-4]fv(index, values) overloads to WebGLContext
  • Methods accept std::vector<float> and forward to command buffer

JavaScript Bindings

  • Exposed vertexAttrib1fv, vertexAttrib2fv, vertexAttrib3fv, vertexAttrib4fv on WebGLRenderingContext
  • Validates argument count and minimum component requirements
  • Supports both Float32Array and regular arrays via GetFloatValuesFromValue

Renderer

  • Implemented OnVertexAttrib[1-4]fv handlers calling glVertexAttrib[1-4]fv
  • Registered all vertex attrib command handlers (scalar and vector versions)

Usage

const gl = canvas.getContext('webgl');
const location = 0;

// Scalar (already existed)
gl.vertexAttrib4f(location, 1.0, 0.0, 0.0, 1.0);

// Vector (new)
gl.vertexAttrib4fv(location, new Float32Array([1.0, 0.0, 0.0, 1.0]));
gl.vertexAttrib4fv(location, [1.0, 0.0, 0.0, 1.0]);

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Implement vertexAttribI4i, I4ui, I4iv, and I4uiv methods feat(webgl): implement vertexAttrib[1234]f[v] vector methods Oct 29, 2025
Copilot AI requested a review from EndlessJour9527 October 29, 2025 07:05
Copilot finished work on behalf of EndlessJour9527 October 29, 2025 07:05
@EndlessJour9527 EndlessJour9527 marked this pull request as ready for review October 29, 2025 07:15
Copilot AI review requested due to automatic review settings October 29, 2025 07:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds support for WebGL vertexAttrib*fv functions (vector versions) to complement the existing scalar vertexAttrib*f functions. The implementation adds four new WebGL API methods: vertexAttrib1fv, vertexAttrib2fv, vertexAttrib3fv, and vertexAttrib4fv.

Key changes:

  • Implements WebGL vector vertex attribute API functions (vertexAttrib1fv through vertexAttrib4fv)
  • Adds command buffer support and OpenGL ES rendering backend handlers
  • Includes minor formatting fixes for namespace closing comments across WebGL binding files

Reviewed Changes

Copilot reviewed 8 out of 24 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/renderer/render_api_opengles.cpp Adds OpenGL handler functions for the four new vertexAttrib*fv commands
src/common/command_buffers/shared.hpp Defines command buffer type enums for the new vertex attribute functions
src/common/command_buffers/details/vertex_attrib.hpp Implements base class and request types for vector vertex attribute commands
src/client/script_bindings/webgl/webgl_rendering_context.hpp Declares the four new vertexAttrib*fv methods in the WebGL context
src/client/script_bindings/webgl/webgl_rendering_context.cpp Implements V8 JavaScript bindings with input validation for the new methods
src/client/graphics/webgl_context.hpp Declares C++ API methods for vertexAttrib*fv with overloads
src/client/graphics/webgl_context.cpp Implements the vertexAttrib*fv methods and command buffer request creation
src/client/script_bindings/webgl/*.{hpp,cpp} Formatting fixes for namespace closing comments (8 files)
src/client/script_bindings/events/all_events.cpp Minor formatting adjustment to function declaration

Comment on lines +442 to +449
void vertexAttrib1fv(const WebGLAttribLocation &, const std::vector<float> values);
void vertexAttrib1fv(int index, const std::vector<float> values);
void vertexAttrib2fv(const WebGLAttribLocation &, const std::vector<float> values);
void vertexAttrib2fv(int index, const std::vector<float> values);
void vertexAttrib3fv(const WebGLAttribLocation &, const std::vector<float> values);
void vertexAttrib3fv(int index, const std::vector<float> values);
void vertexAttrib4fv(const WebGLAttribLocation &, const std::vector<float> values);
void vertexAttrib4fv(int index, const std::vector<float> values);
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values parameter should be passed by const reference (const std::vector<float> &values) instead of by value to avoid unnecessary copying of vector data.

Copilot uses AI. Check for mistakes.
sendCommandBufferRequest(req);
}

void WebGLContext::vertexAttrib1fv(const WebGLAttribLocation &index, const vector<float> values)
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values parameter should be passed by const reference (const vector<float> &values) instead of by value to avoid unnecessary copying of vector data. This matches the pattern used elsewhere in the codebase and improves performance.

Copilot uses AI. Check for mistakes.
sendCommandBufferRequest(req);
}

void WebGLContext::vertexAttrib1fv(int index, const vector<float> values)
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values parameter should be passed by const reference (const vector<float> &values) instead of by value to avoid unnecessary copying of vector data. This matches the pattern used elsewhere in the codebase and improves performance.

Suggested change
void WebGLContext::vertexAttrib1fv(int index, const vector<float> values)
void WebGLContext::vertexAttrib1fv(int index, const vector<float> &values)

Copilot uses AI. Check for mistakes.
sendCommandBufferRequest(req);
}

void WebGLContext::vertexAttrib2fv(const WebGLAttribLocation &index, const vector<float> values)
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values parameter should be passed by const reference (const vector<float> &values) instead of by value to avoid unnecessary copying of vector data. This matches the pattern used elsewhere in the codebase and improves performance.

Copilot uses AI. Check for mistakes.
sendCommandBufferRequest(req);
}

void WebGLContext::vertexAttrib2fv(int index, const vector<float> values)
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values parameter should be passed by const reference (const vector<float> &values) instead of by value to avoid unnecessary copying of vector data. This matches the pattern used elsewhere in the codebase and improves performance.

Copilot uses AI. Check for mistakes.
sendCommandBufferRequest(req);
}

void WebGLContext::vertexAttrib3fv(const WebGLAttribLocation &index, const vector<float> values)
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values parameter should be passed by const reference (const vector<float> &values) instead of by value to avoid unnecessary copying of vector data. This matches the pattern used elsewhere in the codebase and improves performance.

Suggested change
void WebGLContext::vertexAttrib3fv(const WebGLAttribLocation &index, const vector<float> values)
void WebGLContext::vertexAttrib3fv(const WebGLAttribLocation &index, const vector<float> &values)

Copilot uses AI. Check for mistakes.
sendCommandBufferRequest(req);
}

void WebGLContext::vertexAttrib3fv(int index, const vector<float> values)
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values parameter should be passed by const reference (const vector<float> &values) instead of by value to avoid unnecessary copying of vector data. This matches the pattern used elsewhere in the codebase and improves performance.

Copilot uses AI. Check for mistakes.
sendCommandBufferRequest(req);
}

void WebGLContext::vertexAttrib4fv(const WebGLAttribLocation &index, const vector<float> values)
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values parameter should be passed by const reference (const vector<float> &values) instead of by value to avoid unnecessary copying of vector data. This matches the pattern used elsewhere in the codebase and improves performance.

Copilot uses AI. Check for mistakes.
sendCommandBufferRequest(req);
}

void WebGLContext::vertexAttrib4fv(int index, const vector<float> values)
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values parameter should be passed by const reference (const vector<float> &values) instead of by value to avoid unnecessary copying of vector data. This matches the pattern used elsewhere in the codebase and improves performance.

Suggested change
void WebGLContext::vertexAttrib4fv(int index, const vector<float> values)
void WebGLContext::vertexAttrib4fv(int index, const vector<float>& values)

Copilot uses AI. Check for mistakes.
Base automatically changed from feat/support-vertext-attribI4x to main November 3, 2025 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants