How can I set the color of a pixel on a canvas using WebGL?

前端 未结 3 1320
一整个雨季
一整个雨季 2021-02-20 06:08

I am very new to WebGL, but not Javascript or Canvas. Essentially, I need a very fast way to be able to change the color of a pixel on a canvas at any coordinate. I feel like

3条回答
  •  醉梦人生
    2021-02-20 06:44

    You could use GL_POINTS when drawing. Basically you would pass an array of points to the GPU, together with the colors and the positions. You then call drawArrays with the right data.

    This might be too tied to other things, but this might help you:

    https://github.com/funkaster/ChesterGL/blob/master/chesterGL/primitivesBlock.js#L126

    https://github.com/funkaster/ChesterGL/blob/master/chesterGL/primitivesBlock.js#L260

    That's how I render several points in the primitive block for chesterGL.

提交回复
热议问题