there.oughta.be
there.oughta.be copied to clipboard
Single panel
Hi, Great work!
I am trying to modify this code to run on a single panel. My opengl knowledge is not so great! Has anyone succeded in converting it into a single panel? That would be very helpful.
Or provide me with some idea on how to convert the code into a single panel.
Thanks
Haven't tried it, but it should be the following steps:
- Replace all occurences of "196" with "64" as you will be rendering a 64x64 image instead of 192x64.
- Change the vertices to match your one side. Orignally, there are 12 vertices (with 3 coordinates each) defined in https://github.com/Staacks/there.oughta.be/blob/master/led-cube/led-cube/cpu-stats-gl.cpp#L82, which make up a pair of triangles for each side of the cube, so we can map the coordinates for a proper projection. You would not need additional coordinates at all for a single side, but in terms of changing the code, it is probably simpler to just reduce this to four vertices to map the corners of your one face. To do so, remove the four inner blocks of the array, so that you have a total of 12 lines (4 vertices times three coordinates), which are the ones from line 83 to 88 and from line 118 to 123. OpenGL coordinates always range from -1 to +1, regardless of aspect ratio, so this way we simply keep the vertices that match the corners of the image.
- In https://github.com/Staacks/there.oughta.be/blob/master/led-cube/led-cube/cpu-stats-gl.cpp#L126 you will find the "internal" coordinates for the ring mapped to the vertices that we just changed. For a single side this is not really necessary, but as I said, it is probably easier to just keep this concept. Since you are mapping the entire scene onto the entire panel, these coordinates should be the same as the ones for the vertices - except that these are 2D coordinates and you need to remove every third. So, copy the 12 entries from before and remove every third (those should be zero), so you end up with (-1,-1), (-1,+1), (+1,-1) and (+1,+1).
- Thanks to my somewhat unclean coding style, you need to update the number of entries in those arrays in a few places:
- Change 36 to 12 in https://github.com/Staacks/there.oughta.be/blob/master/led-cube/led-cube/cpu-stats-gl.cpp#L481
- Change 24 to 8 in https://github.com/Staacks/there.oughta.be/blob/master/led-cube/led-cube/cpu-stats-gl.cpp#L485
- Change 12 to 4 in https://github.com/Staacks/there.oughta.be/blob/master/led-cube/led-cube/cpu-stats-gl.cpp#L569
I hope I found all locations. Let me know if it worked.