Skip to content

TextureData.Pixels() and PixelsAt() lead to possible misuse of unsafe.Pointer #491

@neclepsio

Description

@neclepsio

Both TextureData.Pixels() and TextureData.PixelsAt() return uintptr.
go-gl requires unsafe.Pointer when setting texture data, so the command is:

gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, tex.Width(), tex.Height(),
	0, gl.RGBA, gl.UNSIGNED_BYTE, unsafe.Pointer(tex.Pixels()))

This requires a conversion from uintptr to unsafe.Pointer, that triggers a warning with go vet and other static analyzers due to it being unsafe (if I understand correctly, it's not).

Maybe Pixels and PixelsAt should return a pointer instead of uintptr?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions