Skip to content

Wrapper: createProgram and createShader can return error. #18

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

Merged
merged 1 commit into from
Jun 25, 2025

Conversation

hazeycode
Copy link
Member

@hazeycode hazeycode commented Jun 25, 2025

Adds some error handling to gl procs that directly return error values.

@hazeycode hazeycode requested a review from Copilot June 25, 2025 00:37
Copy link

@Copilot 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 PR enhances the OpenGL wrapper by adding explicit error handling to createProgram and createShader, turning them into error-returning functions when invalid handles are produced.

  • Change return types of createProgram and createShader to error unions (!Program, !Shader).
  • Introduce checks for invalid handles and return error.glCreateProgramFailed or error.glCreateShaderFailed.
  • Convert the raw integer from the binding into the appropriate enum only on success.
Comments suppressed due to low confidence (2)

src/wrapper.zig:2583

  • [nitpick] Using a quoted identifier can reduce readability; consider renaming the parameter to something like shader_type for clarity.
        pub fn createShader(@"type": ShaderType) !Shader {

src/wrapper.zig:2577

  • There's no test coverage for the failure path when glCreateProgram returns an invalid handle; consider adding a unit test to verify this error is emitted correctly.
                return error.glCreateProgramFailed;

@hazeycode hazeycode merged commit ec38a51 into main Jun 25, 2025
3 checks passed
@hazeycode hazeycode deleted the wrapper-error-handling branch June 25, 2025 00:46
@hazeycode
Copy link
Member Author

hazeycode commented Jun 25, 2025

Folow-up fixes in response to Copilot nitpicks: 2138b1a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant