0

I'm in the process of learning OpenGL and I have already made some simple shaders and programs. However, for my latest project I need to render every pixels colour based on a bunch of data stored in an array. My setup involves sending the data to a fragment shader. Also, since this array contains values for every pixel, I assume it will store WIDTH*HEIGHT values. For example, a window sized 500x500 will correspond to a array of 250,000 values. This array data is continuously updated on the CPU side (Main.cpp) and as far as I can tell uniforms don't meet this size requirement.

Can someone please explain the best way to do this preferably with an example? Also I'm using Modern OpenGl version 4.

EDIT: I have heard that using an SSBO would be a good approach, however, I'm having trouble implementing this.

EDIT: Solved by using Shader Storage Buffer Objects.

Lachy 314
  • 25
  • 7
  • 2
    Use either a [Shader Storage Buffer Object](https://www.khronos.org/opengl/wiki/Shader_Storage_Buffer_Object) or a [Texture](https://www.khronos.org/opengl/wiki/Texture) – Rabbid76 Nov 01 '20 at 11:25
  • 1
    [Shader Storage Buffer Object](https://www.khronos.org/opengl/wiki/Shader_Storage_Buffer_Object) can be updated like any other buffer. See [What is the proper way to modify OpenGL vertex buffer?](https://stackoverflow.com/questions/15821969/what-is-the-proper-way-to-modify-opengl-vertex-buffer) – Rabbid76 Nov 01 '20 at 11:32
  • Can you give an example? I'm having trouble implementing this... – Lachy 314 Nov 02 '20 at 09:05
  • What have you tried so far? – Rabbid76 Nov 02 '20 at 09:17
  • I've tried to apply the example shown on the OpenGL wiki, as well as following the several other guides, but it either shows a black screen or tells me the hardware limit has been exceeded. From what I've read I'm guessing that the hardware limit error is just a result of incorrect code. – Lachy 314 Nov 02 '20 at 09:25
  • And now should I guess your mistake without seeing the code? There is an example in the OpenGL wiki. What other example would you like? – Rabbid76 Nov 02 '20 at 09:36
  • 1
    Solved it. Turned out to be a mistake in the implementation... stupid me. Thanks for the information. – Lachy 314 Nov 02 '20 at 11:06

0 Answers0